Skip to content

Preserve decoded picture timing through video reordering and flush - #6

Open
romaad wants to merge 5 commits into
caseymanos:mainfrom
romaad:fix/decoded-video-frame-timestamps
Open

romaad wants to merge 5 commits into
caseymanos:mainfrom
romaad:fix/decoded-video-frame-timestamps

Conversation

@romaad

@romaad romaad commented Nov 30, 2026

Copy link
Copy Markdown

Problem

With H.264 or HEVC B-frames, FFmpeg may return a picture while a later packet is being submitted. The native decoder was stamping that picture with the current packet’s timestamp and duration. Consumers that use those timestamps to identify decoded pictures could select the wrong frame. Draining the decoder already read timing from the output frame.

Change

Use the timing carried by the FFmpeg output frame in both synchronous and worker mode. Transfer ownership of that frame to the callback. In worker mode, queue each flush completion behind its decoded frames so the caller can safely consume the complete output once flush resolves.

Verification

  • Added synthetic H.264 and HEVC streams with 40 pictures each. Independent FFprobe packet-to-picture mappings define the expected output.
  • Checked synchronous and worker decoding with repeated and negative timestamps and distinct packet durations. The test covers output before and during flush.
  • Exercised consecutive worker flush requests under a busy output queue. Bypassing the output barrier reproduced early flush completion.

@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown

@romaad is attempting to deploy a commit to the Ralc Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Nov 30, 2026

Copy link
Copy Markdown

Your organization has run out of review credits. Add credits to resume code reviews.

This branch has not been deployed

No deployments
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.

1 participant