Repository navigation
fix(desktop-gpui): keep the last frame of imported videos - #2584
Merged
richiemcilroy merged 2 commits intoOct 18, 2026
Merged
Conversation
Contributor
|
@Theophilus2003 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Thanks for merging, @richiemcilroy If it’s useful, #2586 is ready for review too: it makes the recording picker thumbnails up to 4.3x faster on Windows/Linux, with byte-identical output. |
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
Every video imported through the GPUI app comes out one frame short. Follow-up to #2575, where I found this while benchmarking imports.
Cause
H264Output::drain_packetsinapps/desktop-gpui/src/import.rswrites the encoder's packets withduration = 0. libx264 (and VideoToolbox) don't fill it in. The mp4 muxer takes every other sample's duration from the next DTS, so only the final sample ends up with duration 0. The track and edit list therefore end one frame early:test-with-audio.mp4fixture (25 frames, 1.00 s) imports as a file reporting 0.96 s. The mov demuxer flags its last frame as discard, so decoding it yields 24 frames.Fix
The encoder output stores one frame interval in its time base (
frame_duration_ticks). Any packet the encoder leaves without a duration gets that interval beforerescale_ts, so it's rescaled with the timestamps. Packets that already carry a duration are left alone.Tests
a_completed_conversion_keeps_every_source_frame_and_the_audionow also decodes the output: it must decode to all 25 frames and report a 1.00 s duration.left: 24, right: 25). With it, allimport::tests pass.rustfmtclean.

Confidence Score: 5/5
This PR appears safe to merge; no actionable issues were found.Summary
This PR fills missing H.264 packet durations so imported videos keep their final frame.
Reviews (1) · Last reviewed commit: "fix(desktop-gpui): keep the last frame o..." · Reviewed by Greptile