Add explicit FFmpeg trim command logging + duration verification

This commit is contained in:
Sebastjan Artič 2026-04-28 17:17:11 +00:00
parent 8eaef029e2
commit bc3fe1f9d4

View File

@ -235,9 +235,20 @@ def main():
if args.duration is not None:
cmd += ["-t", str(args.duration)]
cmd += ["-c", "copy", tmp.name]
subprocess.run(cmd, check=True, stderr=subprocess.DEVNULL)
print(f"🔧 TRIM CMD: {' '.join(cmd)}", file=sys.stderr)
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(f"❌ TRIM FAILED: {result.stderr[-500:]}", file=sys.stderr)
sys.exit(1)
work_input = Path(tmp.name)
print(f"✂ Trim → {work_input}")
# Verify trim output duration
verify = subprocess.run(
["ffprobe", "-v", "error", "-show_entries", "format=duration",
"-of", "default=nw=1:nokey=1", str(work_input)],
capture_output=True, text=True
)
print(f"🔍 TRIMMED FILE DURATION: {verify.stdout.strip()}s (expected ~{args.duration}s)", file=sys.stderr)
info = get_video_info(work_input)
print(f"📹 Vhod: {info['width']}x{info['height']} @ {info['fps']:.2f}fps, {info['duration']:.1f}s")