Skip to content

fix(desktop-gpui): keep the last frame of imported videos - #2584

Merged
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
Theophilus2003:fix/gpui-import-last-frame
Oct 18, 2026
Merged

richiemcilroy merged 2 commits into
CapSoftware:mainfrom
Theophilus2003:fix/gpui-import-last-frame

Conversation

@Theophilus2003

@Theophilus2003 Theophilus2003 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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_packets in apps/desktop-gpui/src/import.rs writes the encoder's packets with duration = 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:

  • The bundled test-with-audio.mp4 fixture (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.
  • A 60 s 1080p60 import reports 59.983 s and a 30 s 4K30 import 29.967 s. Both lose one frame interval.

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 before rescale_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_audio now also decodes the output: it must decode to all 25 frames and report a 1.00 s duration.
  • Without the fix that test fails (left: 24, right: 25). With it, all import:: tests pass.
  • rustfmt clean.

RetriggerView in GreptileConfidence 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.

  • Imported videos keep their final frame.

Reviews (1) · Last reviewed commit: "fix(desktop-gpui): keep the last frame o..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown
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.

@richiemcilroy
richiemcilroy merged commit ac21523 into CapSoftware:main Oct 18, 2026
36 of 38 checks passed
@Theophilus2003

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants