Repository navigation
Fix a hang with multiple outputs, improve duration detection, add on_progress and a run() result (v7.1.0) - #42
Merged
Conversation
FFmpeg asked whether to overwrite the file and waited for an answer on its standard input pipe, which nothing writes to. Always pass -y or -n so FFmpeg never prompts, and raise FfmpegCommandError when -n makes FFmpeg exit with code 0 without processing anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XaLfYzZiAcNBbUCUoWkAxF
- Duration detection: read concat demuxer lists, pass input options such as -f and -framerate to FFprobe, and account for -stream_loop, -loop, -shortest and -frames:v. FFprobe is not run for capture devices. - Add on_progress, called with an FfmpegProgress that also has the speed, fps, frame, bitrate and percentage. - run() returns an FfmpegResult with the elapsed time and output size. - On Linux, FFmpeg is sent SIGTERM if the Python process dies. - Do not ask whether to overwrite the null device. - Time out hanging tests with pytest-timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XaLfYzZiAcNBbUCUoWkAxF
CrypticSignal
force-pushed
the
claude/dreamy-ramanujan-gqb9xy
branch
from
November 12, 2026 12:25
ff8526b to
333f85f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug fix:
run()could hang forever. If an output other than the last argument already existed (e.g.ffmpeg -i in.mkv -c copy a.mkv -c copy b.mkvwith an existinga.mkv), FFmpeg asked "Overwrite? [y/N]" and waited for an answer on its stdin pipe, which nothing writes to. The command now always gets-yor-n(unless it already has one), so FFmpeg never asks. FFmpeg exits with code 0 when-nmakes it refuse, so that case is detected (FFmpeg always reports progress when it actually runs) and raisesFfmpegCommandError.overwrite=Truenow applies to every output.Duration detection, so more commands get a percentage and ETA:
-f concat -i list.txt): FFprobe can't report a total duration, so the list is read and its files' durations are added up, takinginpoint/outpoint/durationinto account.-f,-framerate,-pattern_type,-start_number,-safe,-protocol_whitelist) are passed to FFprobe. For example, an image sequence with-framerate 5was previously probed at 25 fps. FFprobe is not run for capture devices (v4l2,avfoundation,dshow, …) or lavfi.-stream_loop,-loop 1,-shortestand-frames:v/-vframesare now taken into account. The common-loop 1 -i cover.jpg -i song.mp3 -shortestnow uses the song's duration instead of 0.04 s.New API (additive, no breaking changes):
on_progress: called with anFfmpegProgressdataclass that hassecs,duration_secs,size_mb,percentage,speed,fps,frameandbitrate_kbps.progress_callbackis unchanged.run()returns anFfmpegResultwithelapsed_secs,processed_secs,duration_secs,output_size_mbandlog_file. It used to returnNone.Other changes:
SIGTERM(viaPR_SET_PDEATHSIG) if the Python process dies, e.g. fromSIGKILL. Before, it kept running on its own. macOS and Windows have no simple equivalent, so the README documents it for those./dev/null,NUL) no longer asks whether to overwrite it.test.pyno longer needs-y.pytest-timeout(120 s per test) means a hang fails one test instead of taking up the whole 15-minute CI job.Version bumped to 7.1.0, and the README and CHANGELOG are updated.
Testing
pytest: 104 passed locally on Linux with FFmpeg 6.1.ruff check,ruff format --checkandmypy(strict) are clean.-framerate,-loop 1+-shortest,-stream_loop 2,-stream_loop -1 -t 4and-frames:v 5all get the right expected duration.Generated by Claude Code