Skip to content

Commit 7524962

Browse files
committed
Add support for specifying video codec profile
1 parent 19ef604 commit 7524962

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/flitter/cache.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ def write_image(self, image, quality=None, alpha=False):
406406
self._cache[key] = True
407407

408408
def write_video_frame(self, frame, timestamp, codec='h264', pixfmt='yuv420p', fps=60, realtime=False,
409-
crf=None, preset=None, limit=None, alpha=False):
409+
crf=None, profile=None, preset=None, limit=None, alpha=False):
410410
import av
411411
self._touched = system_clock()
412412
width, height = frame.width, frame.height
413-
key = 'video_output', width, height, alpha, codec, pixfmt, fps, crf, preset, limit
413+
key = 'video_output', width, height, alpha, codec, profile, pixfmt, fps, crf, preset, limit
414414
writer, queue, start = self._cache.get(key, (None, None, None))
415415
if start is None:
416416
self.cleanup()
@@ -424,6 +424,8 @@ def write_video_frame(self, frame, timestamp, codec='h264', pixfmt='yuv420p', fp
424424
options['crf'] = str(crf)
425425
if preset is not None:
426426
options['preset'] = preset
427+
if profile is not None:
428+
options['profile'] = profile
427429
try:
428430
codec = codec.lower()
429431
if codec not in av.codecs_available:

src/flitter/render/window/record.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ def render(self, node, references, *, time=None, fps=None, realtime=None, **kwar
1515
codec = node.get('codec', 1, str, 'h264')
1616
keep_alpha = node.get('keep_alpha', 1, bool, False)
1717
if ext in ('.mp4', '.mov', '.m4v', '.mkv', '.webm', '.ogg') or (ext == '.gif' and codec == 'gif'):
18-
pixfmt = node.get('pixfmt', 1, str, 'rgb8' if codec == 'gif' else 'yuv420p')
18+
pixfmt = node.get('pixfmt', 1, str, 'rgb8' if codec == 'gif' else ('yuva420p' if keep_alpha else 'yuv420p'))
1919
crf = node.get('crf', 1, int)
20+
profile = node.get('profile', 1, str)
2021
preset = node.get('preset', 1, str)
2122
limit = node.get('limit', 1, float)
2223
path.write_video_frame(self._target.video_frame, time, fps=int(fps), realtime=realtime, codec=codec,
23-
pixfmt=pixfmt, crf=crf, preset=preset, limit=limit, alpha=keep_alpha)
24+
pixfmt=pixfmt, crf=crf, profile=profile, preset=preset, limit=limit, alpha=keep_alpha)
2425
else:
2526
quality = node.get('quality', 1, int)
2627
path.write_image(self._target.image, quality=quality, alpha=keep_alpha)

0 commit comments

Comments
 (0)