From 3c2f62dff90a707969f2ba3dd37b58c3a3e0db86 Mon Sep 17 00:00:00 2001 From: Cryator <64459269+Cryator@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:09:17 -0500 Subject: [PATCH] Update HDR check and readd header information with each keyframe. (#4) * Changed HDR handling to use new syntax for svtav1-params as found in https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Parameters.md * Change color space mapping to use a dictionary instead of a single hardcoded mapping. * Update scripts/ffmpeg_automator.py Co-authored-by: Carlos Martinez <18587674+Dashboy1998@users.noreply.github.com> * Update scripts/ffmpeg_automator.py Co-authored-by: Carlos Martinez <18587674+Dashboy1998@users.noreply.github.com> * Update HDR check and re-added repetition headers with svtav1-params. * Update scripts/ffmpeg_automator.py Co-authored-by: Carlos Martinez <18587674+Dashboy1998@users.noreply.github.com> --------- Co-authored-by: Carlos Martinez <18587674+Dashboy1998@users.noreply.github.com> --- scripts/ffmpeg_automator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ffmpeg_automator.py b/scripts/ffmpeg_automator.py index 7a88d5f..2608b8d 100755 --- a/scripts/ffmpeg_automator.py +++ b/scripts/ffmpeg_automator.py @@ -154,7 +154,7 @@ def check_hdr(file_path): for stream in media_info['streams']: if stream['codec_type'] == 'video': if 'color_space' in stream: - hdr = stream.get('color_space') == 'bt2020nc' + hdr = 'bt2020' in stream.get('color_space') break return hdr @@ -217,7 +217,7 @@ def run_ffmpeg(input_path, output_path): if check_hdr(input_path): hdr_settings = get_hdr_setings(input_path) - encode_settings['svtav1-params'] = 'enable-hdr=1:color-primaries={color_primaries}:transfer-characteristics={color_transfer}:matrix-coefficients={color_space}:mastering-display=R({red_x},{red_y})G({green_x},{green_y})B({blue_x},{blue_y})WP({white_point_x},{white_point_y})L({max_luminance},{min_luminance}):content-light={max_content},{max_average} -pix_fmt {pix_fmt}'.format(**hdr_settings) # noqa: E501 + encode_settings['svtav1-params'] = 'enable-hdr=1:repetition_headers=1:color-primaries={color_primaries}:transfer-characteristics={color_transfer}:matrix-coefficients={color_space}:mastering-display=R({red_x},{red_y})G({green_x},{green_y})B({blue_x},{blue_y})WP({white_point_x},{white_point_y})L({max_luminance},{min_luminance}):content-light={max_content},{max_average} -pix_fmt {pix_fmt}'.format(**hdr_settings) # noqa: E501 ffmpeg = ( FFmpeg().input(input_path).output(