revert changes the process-call to include the svtav1encapp - stats into the log-file
This commit is contained in:
2025-08-11 12:23:46 +02:00
parent a1ba3beb8b
commit 797fcaae0a

View File

@@ -219,39 +219,11 @@ def convert_video(source_file_base, source_file_full, is_vfr, target_cfr_fps_for
)
print(f" - Running: {' '.join(ffmpeg_pipe_cmd)} | {' '.join(svtav1_cmd)}")
# Use subprocess.Popen for piping and tee SvtAv1EncApp output
import threading
# Save the original stdout (console) before redirection
original_console = sys.__stdout__
# Use subprocess.Popen for piping
with subprocess.Popen(ffmpeg_pipe_cmd, stdout=subprocess.PIPE) as ffmpeg_proc:
with subprocess.Popen(
svtav1_cmd,
stdin=ffmpeg_proc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
text=True
) as svt_proc:
with subprocess.Popen(svtav1_cmd, stdin=ffmpeg_proc.stdout) as svt_proc:
ffmpeg_proc.stdout.close() # Allow ffmpeg_proc to receive a SIGPIPE if svt_proc exits
def tee_output(proc_stdout, log_file, console):
for line in proc_stdout:
# Write to log file (current sys.stdout)
print(line, end='') # Goes to log file
# Write to console
if console:
try:
console.write(line)
console.flush()
except Exception:
pass
tee_thread = threading.Thread(target=tee_output, args=(svt_proc.stdout, sys.stdout, original_console))
tee_thread.start()
svt_proc.wait()
tee_thread.join()
svt_proc.communicate()
if svt_proc.returncode != 0:
raise RuntimeError(f"SvtAv1EncApp failed with exit code {svt_proc.returncode}")