diff --git a/transcode.py b/transcode.py index a1b1383..7ceaed0 100644 --- a/transcode.py +++ b/transcode.py @@ -386,14 +386,17 @@ def transcode_file(input_file, output_file=None, skip_av1=True, replace_mode=Fal logging.warning(f"File vanished during checks: {input_path}") return - # 3. Check Codec - if skip_av1: - codec = get_video_codec(input_path) - if codec == "av1": - logging.info(leftalign(f"SKIP: Input file is already AV1: {input_path}")) - return - else: - logging.info(leftalign(f"Codec is {codec}")) + # 3. Check Codec (Combined step) + # We grab the codec here to check if we should skip, AND we save it to + # 'original_codec' so we don't have to re-scan the file at the end. + original_codec = get_video_codec(input_path) + + if skip_av1 and original_codec == "av1": + logging.info(leftalign(f"SKIP: Input file is already AV1: {input_path}")) + return + + if original_codec: + logging.info(leftalign(f"Codec is {original_codec}")) # Prepare individual FFmpeg log file ffmpeg_logs_dir = get_config_dir() / "ffmpeg_logs" @@ -478,8 +481,6 @@ def transcode_file(input_file, output_file=None, skip_av1=True, replace_mode=Fal logging.debug(f"Transcoding duration was {transcoding_duration}.") - original_codec = get_video_codec(input_path) - # Update cache for the NEW file (which is now AV1) # This ensures if we restart, we know this new file is already done if replace_mode and use_temp_file: