oddity-ai / video-rs

Video readers, writers, muxers, encoders and decoders for Rust based on ffmpeg libraries.
Apache License 2.0
231 stars 28 forks source link

Support selecting a specific stream #31

Open EvysGarden opened 8 months ago

EvysGarden commented 8 months ago

Problem

I am using your crate for a pixelflut and am trying to livestream from a m3u8 file. It has several video streams with different resolutions and i want to be able to select a specific stream.

What I have done so far

I've looked into your reader and you are perfectly able to query for streams but there is currently no way to make use of that info as the stream is always selected with best_video_stream_index().

Feature request

It would be nice to expose the stream selection to the user. Something like this:

Best selection

let source = Locator::Url(...);
let decoder = Decoder::new(&source, StreamSelection::Best)?;

Manual selection

let source = Locator::Url(...);
let decoder = Decoder::new(&source, StreamSelection::Index(2))?;
gerwin3 commented 4 months ago

This is quite trivial to implement now since #37 has been merged with builder pattern everywhere.