realtime console output preferred
This commit is contained in:
@@ -224,32 +224,20 @@ final_clip.set_output()
|
|||||||
svtav1_cmd = ["SvtAv1EncApp2"] + svtav1_param_list + ["-i", "-", "-b", str(encoded_video_file)]
|
svtav1_cmd = ["SvtAv1EncApp2"] + svtav1_param_list + ["-i", "-", "-b", str(encoded_video_file)]
|
||||||
|
|
||||||
print(f" - Running: {' '.join(vspipe_cmd)} | {' '.join(svtav1_cmd)}")
|
print(f" - Running: {' '.join(vspipe_cmd)} | {' '.join(svtav1_cmd)}")
|
||||||
import tempfile
|
|
||||||
|
|
||||||
# Create a temp file to capture SvtAv1EncApp2 output
|
|
||||||
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8", delete=False) as svtav1_temp_log:
|
|
||||||
temp_log_path = svtav1_temp_log.name
|
|
||||||
|
|
||||||
with subprocess.Popen(vspipe_cmd, stdout=subprocess.PIPE) as vspipe_proc:
|
with subprocess.Popen(vspipe_cmd, stdout=subprocess.PIPE) as vspipe_proc:
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
svtav1_cmd,
|
svtav1_cmd,
|
||||||
stdin=vspipe_proc.stdout,
|
stdin=vspipe_proc.stdout,
|
||||||
stdout=subprocess.PIPE,
|
stdout=None, # Let output go directly to the console
|
||||||
stderr=subprocess.STDOUT,
|
stderr=None
|
||||||
bufsize=1,
|
) as svt_proc:
|
||||||
text=True
|
|
||||||
) as svt_proc, open(temp_log_path, "w", encoding="utf-8") as svt_log:
|
|
||||||
vspipe_proc.stdout.close()
|
vspipe_proc.stdout.close()
|
||||||
# Print to console and write to temp file
|
|
||||||
for line in svt_proc.stdout:
|
|
||||||
print(line, end="")
|
|
||||||
svt_log.write(line)
|
|
||||||
svt_proc.wait()
|
svt_proc.wait()
|
||||||
if svt_proc.returncode != 0:
|
if svt_proc.returncode != 0:
|
||||||
raise RuntimeError(f"SvtAv1EncApp failed with exit code {svt_proc.returncode}")
|
raise RuntimeError(f"SvtAv1EncApp failed with exit code {svt_proc.returncode}")
|
||||||
|
|
||||||
print(" --- Finished Video Processing ---")
|
print(" --- Finished Video Processing ---")
|
||||||
return encoded_video_file, handbrake_cfr_intermediate_file, temp_log_path
|
return encoded_video_file, handbrake_cfr_intermediate_file, None
|
||||||
|
|
||||||
def is_ffmpeg_decodable(file_path):
|
def is_ffmpeg_decodable(file_path):
|
||||||
try:
|
try:
|
||||||
@@ -543,7 +531,6 @@ def main(no_downmix=False, autocrop=False, speed=None, quality=None, grain=None)
|
|||||||
intermediate_output_file = current_dir / f"output-{file_path.name}"
|
intermediate_output_file = current_dir / f"output-{file_path.name}"
|
||||||
audio_temp_dir = None
|
audio_temp_dir = None
|
||||||
handbrake_intermediate_for_cleanup = None
|
handbrake_intermediate_for_cleanup = None
|
||||||
svtav1_temp_log_path = None
|
|
||||||
try:
|
try:
|
||||||
audio_temp_dir = tempfile.mkdtemp(prefix="anime_audio_")
|
audio_temp_dir = tempfile.mkdtemp(prefix="anime_audio_")
|
||||||
print(f"Audio temporary directory created at: {audio_temp_dir}")
|
print(f"Audio temporary directory created at: {audio_temp_dir}")
|
||||||
@@ -606,35 +593,10 @@ def main(no_downmix=False, autocrop=False, speed=None, quality=None, grain=None)
|
|||||||
else:
|
else:
|
||||||
print(" - No crop needed or detected.")
|
print(" - No crop needed or detected.")
|
||||||
|
|
||||||
# --- Video encoding: get temp log path ---
|
encoded_video_file, handbrake_intermediate_for_cleanup, _ = convert_video(
|
||||||
encoded_video_file, handbrake_intermediate_for_cleanup, svtav1_temp_log_path = convert_video(
|
|
||||||
file_path.stem, str(input_file_abs), is_vfr, target_cfr_fps_for_handbrake, autocrop_filter=autocrop_filter
|
file_path.stem, str(input_file_abs), is_vfr, target_cfr_fps_for_handbrake, autocrop_filter=autocrop_filter
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- After encoding, append summary lines from temp log to main log ---
|
|
||||||
if svtav1_temp_log_path:
|
|
||||||
try:
|
|
||||||
with open(svtav1_temp_log_path, "r", encoding="utf-8") as svt_log:
|
|
||||||
lines = svt_log.readlines()
|
|
||||||
# Find the summary section (look for 'SUMMARY' or last 20 lines)
|
|
||||||
summary_start = None
|
|
||||||
for i, line in enumerate(lines):
|
|
||||||
if 'SUMMARY' in line:
|
|
||||||
summary_start = i
|
|
||||||
break
|
|
||||||
summary_lines = lines[summary_start:] if summary_start is not None else lines[-20:]
|
|
||||||
print("\n--- SvtAv1EncApp2 SUMMARY ---\n")
|
|
||||||
for l in summary_lines:
|
|
||||||
print(l, end="")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[WARN] Could not append SvtAv1EncApp2 summary to log: {e}")
|
|
||||||
finally:
|
|
||||||
import os
|
|
||||||
try:
|
|
||||||
os.remove(svtav1_temp_log_path)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print("--- Starting Audio Processing ---")
|
print("--- Starting Audio Processing ---")
|
||||||
processed_audio_files = []
|
processed_audio_files = []
|
||||||
audio_tracks_to_remux = []
|
audio_tracks_to_remux = []
|
||||||
|
|||||||
Reference in New Issue
Block a user