Restore the working
This commit is contained in:
@@ -11,7 +11,7 @@ from pathlib import Path
|
||||
|
||||
REQUIRED_TOOLS = [
|
||||
"ffmpeg", "ffprobe", "mkvmerge", "mkvpropedit",
|
||||
"sox", "opusenc", "mediainfo", "av1an", "HandBrakeCLI" # Added HandBrakeCLI
|
||||
"sox_ng", "opusenc", "mediainfo", "av1an", "HandBrakeCLI" # Added HandBrakeCLI
|
||||
]
|
||||
DIR_COMPLETED = Path("completed")
|
||||
DIR_ORIGINAL = Path("original")
|
||||
@@ -69,7 +69,7 @@ def convert_audio_track(index, ch, lang, audio_temp_dir, source_file, should_dow
|
||||
|
||||
print(f" - Normalizing Audio Track #{index} with SoX...")
|
||||
run_cmd([
|
||||
"sox", str(temp_extracted), str(temp_normalized), "-S", "--temp", str(audio_temp_path), "--guard", "gain", "-n"
|
||||
"sox_ng", str(temp_extracted), str(temp_normalized), "-S", "--temp", str(audio_temp_path), "--guard", "gain", "-n"
|
||||
])
|
||||
|
||||
# Set bitrate based on the final channel count of the Opus file.
|
||||
@@ -103,6 +103,7 @@ def convert_audio_track(index, ch, lang, audio_temp_dir, source_file, should_dow
|
||||
def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for_handbrake, autocrop_filter=None):
|
||||
print(" --- Starting Video Processing ---")
|
||||
# source_file_base is file_path.stem (e.g., "my.anime.episode.01")
|
||||
scene_file = Path(f"{source_file_base}.txt")
|
||||
vpy_file = Path(f"{source_file_base}.vpy")
|
||||
ut_video_file = Path(f"{source_file_base}.ut.mkv")
|
||||
encoded_video_file = Path(f"temp-{source_file_base}.mkv")
|
||||
@@ -175,6 +176,15 @@ clip.set_output()
|
||||
with vpy_file.open("w", encoding="utf-8") as f:
|
||||
f.write(vpy_script_content)
|
||||
|
||||
if not scene_file.exists():
|
||||
print(" - Performing scene detection with av1an...")
|
||||
av1an_sc_args = [
|
||||
"av1an", "-i", str(vpy_file), "-s", str(scene_file), "--sc-only", "--verbose"
|
||||
]
|
||||
run_cmd(av1an_sc_args)
|
||||
else:
|
||||
print(" - Found existing scene file, skipping detection.")
|
||||
|
||||
print(" - Starting AV1 encode with av1an (this will take a long time)...")
|
||||
total_cores = os.cpu_count() or 4 # Fallback if cpu_count is None
|
||||
workers = max(1, (total_cores // 2) - 1) # Half the cores minus one, with a minimum of 1 worker.
|
||||
@@ -185,7 +195,7 @@ clip.set_output()
|
||||
print(f" - Using SVT-AV1 parameters: {av1an_video_params_str}")
|
||||
|
||||
av1an_enc_args = [
|
||||
"av1an", "-i", str(vpy_file), "-o", str(encoded_video_file), "-n",
|
||||
"av1an", "-i", str(vpy_file), "-o", str(encoded_video_file), "-s", str(scene_file), "-n",
|
||||
"-e", "svt-av1", "--resume", "--sc-pix-format", "yuv420p", "-c", "mkvmerge",
|
||||
"--set-thread-affinity", "2", "--pix-format", "yuv420p10le", "--force",
|
||||
"-w", str(workers),
|
||||
@@ -647,6 +657,7 @@ def main(no_downmix=False, autocrop=False, speed=None, quality=None, grain=None)
|
||||
|
||||
print("Cleaning up persistent video temporary files (after successful processing)...")
|
||||
video_temp_files_on_success = [
|
||||
current_dir / f"{file_path.stem}.txt",
|
||||
current_dir / f"{file_path.stem}.vpy",
|
||||
current_dir / f"{file_path.stem}.ut.mkv",
|
||||
current_dir / f"temp-{file_path.stem}.mkv", # This is encoded_video_file
|
||||
|
||||
Reference in New Issue
Block a user