revert Updated "frame_count" messuare for faster calculation
This commit is contained in:
2025-08-02 15:49:33 +02:00
parent 78a92a4655
commit 8963248ffb

View File

@@ -183,7 +183,7 @@ def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for
# --- SVT-AV1 ENCODING (ffmpeg pipe to SvtAv1EncApp) --- # --- SVT-AV1 ENCODING (ffmpeg pipe to SvtAv1EncApp) ---
print(" - Starting AV1 encode with ffmpeg -> SvtAv1EncApp pipe (this will take a long time)...") print(" - Starting AV1 encode with ffmpeg -> SvtAv1EncApp pipe (this will take a long time)...")
# Probe UTVideo file for width, height (ffprobe) and frame count (mediainfo, fallback to ffprobe) # Probe UTVideo file for width, height, and frame count
ffprobe_dim_cmd = [ ffprobe_dim_cmd = [
"ffprobe", "-v", "error", "-select_streams", "v:0", "ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height", "-of", "json", ut_video_full_path "-show_entries", "stream=width,height", "-of", "json", ut_video_full_path
@@ -193,27 +193,14 @@ def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for
width = ffprobe_dim['streams'][0]['width'] width = ffprobe_dim['streams'][0]['width']
height = ffprobe_dim['streams'][0]['height'] height = ffprobe_dim['streams'][0]['height']
# Try to get frame count from mediainfo (faster) ffprobe_framecount_cmd = [
mediainfo_json = run_cmd([ "ffprobe", "-v", "error", "-select_streams", "v:0",
"mediainfo", "--Output=JSON", "-f", ut_video_full_path "-count_frames", "-show_entries", "stream=nb_read_frames",
], capture_output=True) "-of", "json", ut_video_full_path
media_info = json.loads(mediainfo_json) ]
frame_count = None ffprobe_framecount_json = run_cmd(ffprobe_framecount_cmd, capture_output=True)
for track in media_info.get("media", {}).get("track", []): ffprobe_framecount = json.loads(ffprobe_framecount_json)
if track.get("@type") == "Video": frame_count = int(ffprobe_framecount['streams'][0].get('nb_read_frames', 0))
frame_count = int(track.get("FrameCount", 0))
break
# Fallback to ffprobe if mediainfo fails
if not frame_count:
ffprobe_framecount_cmd = [
"ffprobe", "-v", "error", "-select_streams", "v:0",
"-count_frames", "-show_entries", "stream=nb_read_frames",
"-of", "json", ut_video_full_path
]
ffprobe_framecount_json = run_cmd(ffprobe_framecount_cmd, capture_output=True)
ffprobe_framecount = json.loads(ffprobe_framecount_json)
frame_count = int(ffprobe_framecount['streams'][0].get('nb_read_frames', 0))
svtav1_param_list = [ svtav1_param_list = [
"--input-depth", "10", "--input-depth", "10",