Skip to content

Commit 2b2c812

Browse files
committed
Allow converting sequences with missing frames
The ffmpeg video conversion failed previously when the source image sequence had missing frames. This patch allows copying the last existing image for all subsequente missing frames.
1 parent 58c484e commit 2b2c812

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

bookmarks/external/ffmpeg_widget.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,23 @@ def save_changes(self):
165165
pbar = ffmpeg.get_progress_bar(start_n, end_n)
166166
pbar.open()
167167

168-
for n in range(start_n, end_n + 1):
168+
# Get all frames from first until the last frame
169+
all_frames = [f'{f}'.zfill(padding) for f in range(start_n, end_n + 1)]
170+
available_frames = common.is_collapsed(self._file).group(2).strip(common.SEQSTART).strip(common.SEQEND).split(',')
171+
available_frames_it = (f for f in available_frames)
172+
173+
# Loop through all frames
174+
# Note all of these frames might refer to a real file on disk, so we'll increment
175+
# the available frame number as we're looping
176+
_frame = available_frames[0]
177+
for n, frame in enumerate(all_frames):
169178
pbar.setValue(n)
170179

171-
n = f'{n}'.zfill(padding)
172-
source = f'{start_seq.group(1)}{n}{start_seq.group(3)}.{start_seq.group(4)}'
173-
file_info = QtCore.QFileInfo(source)
174-
destination = f'{file_info.path()}/temp_{file_info.baseName()}.jpg'
180+
if frame in available_frames:
181+
_frame = next(available_frames_it)
182+
183+
source = f'{start_seq.group(1)}{_frame}{start_seq.group(3)}.{start_seq.group(4)}'
184+
destination = f'{start_seq.group(1)}{frame}{start_seq.group(3)}_ffmpegtemp.jpg'
175185
_destinations.append(destination)
176186

177187
# Convert to jpeg
@@ -183,7 +193,7 @@ def save_changes(self):
183193
pbar.close()
184194

185195
file_info = QtCore.QFileInfo(self._file)
186-
_file = f'{file_info.path()}/temp_{file_info.baseName()}.jpg'
196+
_file = f'{file_info.path()}/{file_info.baseName()}_ffmpegtemp.jpg'
187197

188198
mov = ffmpeg.convert(
189199
_file,

0 commit comments

Comments
 (0)