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)]
|
||||
|
||||
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(
|
||||
svtav1_cmd,
|
||||
stdin=vspipe_proc.stdout,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
bufsize=1,
|
||||
text=True
|
||||
) as svt_proc, open(temp_log_path, "w", encoding="utf-8") as svt_log:
|
||||
stdout=None, # Let output go directly to the console
|
||||
stderr=None
|
||||
) as svt_proc:
|
||||
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()
|
||||
if svt_proc.returncode != 0:
|
||||
raise RuntimeError(f"SvtAv1EncApp failed with exit code {svt_proc.returncode}")
|
||||
|
||||
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):
|
||||
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}"
|
||||
audio_temp_dir = None
|
||||
handbrake_intermediate_for_cleanup = None
|
||||
svtav1_temp_log_path = None
|
||||
try:
|
||||
audio_temp_dir = tempfile.mkdtemp(prefix="anime_audio_")
|
||||
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:
|
||||
print(" - No crop needed or detected.")
|
||||
|
||||
# --- Video encoding: get temp log path ---
|
||||
encoded_video_file, handbrake_intermediate_for_cleanup, svtav1_temp_log_path = convert_video(
|
||||
encoded_video_file, handbrake_intermediate_for_cleanup, _ = convert_video(
|
||||
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 ---")
|
||||
processed_audio_files = []
|
||||
audio_tracks_to_remux = []
|
||||
|
||||
Reference in New Issue
Block a user