Skip to content

Commit b27896e

Browse files
committed
Merge pull request #117 from aestrivex/allow_no_codec_ffmpeg_compat
allow codec to be none for old versions of ffmpeg
2 parents 7d7373b + f47af04 commit b27896e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

surfer/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,10 @@ def ffmpeg(dst, frame_path, framerate=24, codec='mpeg4'):
674674
Path to the source frames (with a frame number field like '%04d').
675675
framerate : float
676676
Framerate of the movie (frames per second, default 24).
677-
codec : str
678-
Codec to use (default 'mpeg4').
677+
codec : str | None
678+
Codec to use (default 'mpeg4'). If None, the codec argument is not
679+
forwarded to ffmpeg, which preserves compatibility with very old
680+
versions of ffmpeg
679681
680682
Notes
681683
-----
@@ -701,7 +703,10 @@ def ffmpeg(dst, frame_path, framerate=24, codec='mpeg4'):
701703
frame_dir, frame_fmt = os.path.split(frame_path)
702704

703705
# make the movie
704-
cmd = ['ffmpeg', '-i', frame_fmt, '-r', str(framerate), '-c', codec, dst]
706+
cmd = ['ffmpeg', '-i', frame_fmt, '-r', str(framerate)]
707+
if codec is None:
708+
cmd += ['-c', codec]
709+
cmd += [dst]
705710
logger.info("Running FFmpeg with command: %s", ' '.join(cmd))
706711
sp = subprocess.Popen(cmd, cwd=frame_dir, stdout=subprocess.PIPE,
707712
stderr=subprocess.PIPE)

0 commit comments

Comments
 (0)