crossfade_concat: frame-exact chain; fix silent xfade truncation - #17
Merged
Conversation
DESCRIPTION: single-quote 'FFmpeg' / 'OpenTimelineIO' / 'rotio' in Title and Description, add reference URLs for FFmpeg and OpenTimelineIO, and add URL/BugReports pointing at the GitHub repo. Add an @examples block to the exported align_overlaps(), and @param/@return to the internal rms helpers. Examples stay \dontrun: they need the ffmpeg binary (a SystemRequirement, not guaranteed on CRAN check hosts) plus user-supplied media files.
ffmpeg's xfade truncates its output silently when offset + duration lands past the first input's end by even float dust, and seconds-based trim windows lose a frame to rounding; across several joins the drift compounds and the chain collapses (a 30s track rendered 8s of motion, then tpad froze the last frame -- caption and all -- for 22s). Run the whole chain in frame arithmetic: trim=start_frame/end_frame for frame-exact feeds, nb_frames-based durations, an integer frame accumulator, and a quarter-frame early bias on every xfade offset so the dissolve always ends strictly on the first input's last frame.
TroyHernandez
added a commit
that referenced
this pull request
Jul 20, 2026
* Add still_clip(), frames_clip(), audio_concat() Three call-by-call primitives for slide/scene assembly: - still_clip(): one image -> a video clip, static or animated by a deterministic Ken Burns pan/zoom (zoompan with eased zoom + anchor expressions, crop clamped to frame). Same encode settings as crossfade_concat() so outputs stay concat-compatible. - frames_clip(): a numbered frame sequence -> a video clip; the landing pad for programmatically drawn animations. - audio_concat(): join audio files through the concat filter with exact anullsrc silences between and after them, normalizing rate/layout; built for assembling a narration bed from per-segment TTS takes. * rformat + document * crossfade_concat: probe fps lazily for the single-clip passthrough Since the frame-exact chain (#17), crossfade_concat probed videos[1] unconditionally, so the single-clip dry_run path errored on files that don't exist yet (test_crossfade.R line 6 has been failing since). Only probe when a join, window, or audio overlay actually needs the rate. * Bump version to 0.1.0.10
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.
ffmpeg's
xfadesilently truncates whenoffset + durationpasses the first input's end by any amount — even float dust — and%g-formatted seconds guarantee dust. Seconds-basedtrimwindows additionally lose ±1 frame to rounding, and the error compounds across a chain: an 8-chunk track assembled 8.3s of motion out of 30.8s, thentpadfroze the last frame (burned caption included) for 22 seconds.Repro (silent, no warnings):
[a][b]xfade=duration=0.0416667:offset=3.66667where input a is 3.7083333s → 103 frames out instead of 189.offset=3.65625(quarter frame early) → 189. The 9-frame fades used previously stayed under the boundary by rounding luck; the container backend's 1-2 frame conditioning heads surfaced it.trim=start_frame/end_framefor frame-exact feeds (seconds trims dropped a frame: 97 vs 98)nb_frames-based feed durations, integer frame accumulator%.6fformattingrender_timeline,cornductor::render_chainedVerified: the failing 8-chunk timeline now assembles 741 frames / 30.875s with motion throughout.