From 285568f5303b9cf5b8754d4dee3fcd9996d76173 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Sat, 26 Jul 2025 15:38:20 -0500 Subject: [PATCH] Use libvpx-vp9 for main decode too An extra pass was added to the ffmpeg_frame_generation code to properly detect and handle alpha when loading vp9 videos. This early commit allowed for correct detection, but then failed to apply the decoder to the main pass, so no alpha was output. This has been fixed. --- videohelpersuite/load_video_nodes.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/videohelpersuite/load_video_nodes.py b/videohelpersuite/load_video_nodes.py index f94c608..03f4f1a 100644 --- a/videohelpersuite/load_video_nodes.py +++ b/videohelpersuite/load_video_nodes.py @@ -170,7 +170,8 @@ def cv_frame_generator(video, force_rate, frame_load_cap, skip_first_frames, def ffmpeg_frame_generator(video, force_rate, frame_load_cap, start_time, custom_width, custom_height, downscale_ratio=8, meta_batch=None, unique_id=None): - args_dummy = [ffmpeg_path, "-i", video, '-c', 'copy', '-frames:v', '1', "-f", "null", "-"] + args_input = ["-i", video] + args_dummy = [ffmpeg_path] + args_input +['-c', 'copy', '-frames:v', '1', "-f", "null", "-"] size_base = None fps_base = None try: @@ -181,7 +182,8 @@ def ffmpeg_frame_generator(video, force_rate, frame_load_cap, start_time, + e.stderr.decode(*ENCODE_ARGS)) lines = dummy_res.stderr.decode(*ENCODE_ARGS) if "Video: vp9 " in lines: - args_dummy = args_dummy[:1] + ["-c:v", "libvpx-vp9"] + args_dummy[1:] + args_input = ["-c:v", "libvpx-vp9"] + args_input + args_dummy = [ffmpeg_path] + args_input +['-c', 'copy', '-frames:v', '1', "-f", "null", "-"] try: dummy_res = subprocess.run(args_dummy, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True) @@ -214,15 +216,13 @@ def ffmpeg_frame_generator(video, force_rate, frame_load_cap, start_time, if start_time > 0: if start_time > 4: post_seek = ['-ss', '4'] - pre_seek = ['-ss', str(start_time - 4)] + args_input = ['-ss', str(start_time - 4)] + args_input else: post_seek = ['-ss', str(start_time)] - pre_seek = [] else: - pre_seek = [] post_seek = [] - args_all_frames = [ffmpeg_path, "-v", "error", "-an"] + pre_seek + \ - ["-i", video, "-pix_fmt", "rgba64le"] + post_seek + args_all_frames = [ffmpeg_path, "-v", "error", "-an"] + \ + args_input + ["-pix_fmt", "rgba64le"] + post_seek vfilters = [] if force_rate != 0: