Repository navigation
Clamp clip duration to the footage remaining after skip_time #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
13972f8
Clamp clip duration to the footage remaining after skip_time
christophervoelpel a0f3132
Preserve explicit duration when media duration is unknown
christophervoelpel 848cc9c
Add _clean_duration docstring sections and wrap >80-col test lines
christophervoelpel 453ca1e
Require an explicit duration when source duration is unknown
christophervoelpel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
source_duration <= 0(unprobeable container duration) and the caller passesduration <= 0(such as the-1default inactions/combine_video.pymeaning "use the rest of the clip"),_clean_durationenters theelsebranch (effective_duration = min(0.0, 0.0) = 0.0) andmax(1, round(0.0 / frame_duration))evaluates to1frame (1.0 / target_fps, ~0.033s). Instead of failing fast,combine()then passesduration=0.0333...totrimandatrim, silently truncating the entire clip to a single frame.Raising a
ValueErrorwhen bothduration <= 0andsource_duration <= 0ensures unprobeable clips require an explicit positive duration rather than silently rendering 1 frame.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, applied in 453ca1e (also added a
Raises:section to the docstring).This was worse than a silent truncation relative to
main, which I checked with real ffmpeg on a 3 s clip. Onmain, this path producedclean_duration = 0, and ffmpeg treatstrim=duration=0as no limit, so the output was the full 3.000 s. With themax(1, ...)in this PR, it becametrim=duration=0.0333→ 0.033 s output. So the PR had turned "whole clip" into "one frame". Failing fast is the right call, since a 0 duration would also corrupt the xfade offset arithmetic.New test
test_unknown_source_duration_requires_explicit_duration: it fails against the previous commit and passes now, and it also asserts nothing was appended toinputs.