Updated "frame_count" messuare for faster calculation

This commit is contained in:
2025-08-02 13:52:51 +02:00
parent b3c993b4a0
commit 4b79cf35d2

View File

@@ -161,7 +161,7 @@ def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for
# --- SVT-AV1 ENCODING (ffmpeg pipe to SvtAv1EncApp) ---
print(" - Starting AV1 encode with ffmpeg -> SvtAv1EncApp pipe (this will take a long time)...")
# Probe UTVideo file for width, height, and frame count
# Probe UTVideo file for width, height (ffprobe) and frame count (mediainfo, fallback to ffprobe)
ffprobe_dim_cmd = [
"ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height", "-of", "json", ut_video_full_path
@@ -171,6 +171,19 @@ def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for
width = ffprobe_dim['streams'][0]['width']
height = ffprobe_dim['streams'][0]['height']
# Try to get frame count from mediainfo (faster)
mediainfo_json = run_cmd([
"mediainfo", "--Output=JSON", "-f", ut_video_full_path
], capture_output=True)
media_info = json.loads(mediainfo_json)
frame_count = None
for track in media_info.get("media", {}).get("track", []):
if track.get("@type") == "Video":
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",