Skip to content
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

Fix playback issues with some h264 videos on native & Safari #8850

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Jan 29, 2025

Related

What

Works around the issue outlined in #8848
In a nutshell: For certain videos we would only ever receive frames that are 16 frames behind of what we enqueued, completely disregarding the fact that we always enqueue full GOPs (I repeatedly confirmed that this is the case with different tools). This affects only h264 on the ffmpeg-cli & WebCodec @ Safari decoders. The exact circumstances that make some videos require this and other not are unknown at this point.

This is "solved" here by making our frame enqueing process more flexible and allowing decoder implementations to specify a "minimum look ahead" number of frames.
Note that oftentimes we still enqueue much more frames regardless: We still want to enqueue the entire current & next GOP for smooth transitions. Typically two h264 GOPs encompass a lot more frames than requested here (citation needed). However, the tested problematic videos operate with GOPs that contain only two frames (single I & P frame) so there this actually makes a difference.

Testing: Beyond the actual video, I tested various samples form our internal library of "curious videos to test" to ensure that the adjusted enqueuing logic doesn't regress anything. (personally, I think it's actually much nicer independent of the workaround :))

Copy link

github-actions bot commented Jan 29, 2025

Web viewer built successfully. If applicable, you should also test it:

  • I have tested the web viewer
Result Commit Link Manifest
fbcbb4d https://rerun.io/viewer/pr/8850 +nightly +main

Note: This comment is updated whenever you push a commit.

@Wumpf Wumpf force-pushed the andreas/video-aggressive-enqueueing branch from b830460 to c6670ba Compare January 29, 2025 13:04
Comment on lines +277 to +278
// (potentially related to:) TODO(#7327, #7595): We don't necessarily have to enqueue full GOPs always.
// In particularly beyond `requested_gop_idx` this can be overkill.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a pre-existing issue, it just wasn't referenced here before

Comment on lines 226 to +228
// By resetting the current GOP/sample indices, the frame enqueued code below
// is forced to reset the decoder.
self.current_gop_idx = usize::MAX;
self.current_sample_idx = usize::MAX;
self.last_requested_gop_idx = usize::MAX;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit wonky imho - why not just self.reset directly. A: This would lead to a double reset.
In the interest of keeping the changes here more minimal I'm not touching this piece

@jprochazk jprochazk self-requested a review January 29, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants