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

expose try_read_decoded_frame to help with real-time use cases #208

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

Conversation

jbrough
Copy link

@jbrough jbrough commented Oct 13, 2024

hey guys, I have a simple use case where I want to pass XcoderDecoder a buffer that is actually a ring buffer (rtrb in this case) rather than a Vec so that I can add frames to the decoder from another thread (eg to support real-time scaling of a live broadcast)

That all works with no library changes due to the flexible iterable trait on the frames input: https://github.com/wavey-ai/xcoder-queue/blob/main/src/lib.rs

But it requires try_read_decoded_frame to be public so the decoder can be saturated with enough initial frames without blocking the producer:

for frame in frames {
    producer_queue.push(frame);
    // these calls will eventually interleave but the decoder needs more than one initial frame to get rollling
    if let Some(decoded_frame) = decoder.try_read_decoded_frame().expect("Failed to read frame") {
        // do something real-time
    }
}

also, I had to make mod linux_imp public to be able to access XcoderPixelFormat in the test (and eventually will be needed in the prod code that uses av-rs) but I feel I may be doing something wrong, there.

(I've tested this tweaked approach with NetINT Quadra on their demo server and its working well, produces a scaled, playable h264 with the decorder+scaler interleaving output frames as I add them to the decoder)

@jbrough jbrough changed the title expose try_read_decoded_frame to help with realtime use-cases expose try_read_decoded_frame to help with real-time use cases Oct 13, 2024
@Xaeroxe Xaeroxe requested a review from scottlamb October 14, 2024 15:46
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