-
Notifications
You must be signed in to change notification settings - Fork 32
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
Spelling and player for streaming video over UDP socket #3
base: main
Are you sure you want to change the base?
Conversation
Also added a simple example with the Player. |
thanks for this! ill check it out and try to get it in along with the upcoming subtitle additions |
Sounds good. Let me know if you want me to make adjustments.
The above has been removed, so |
sorry for the delay, just got through midterm season tried out the branch, and it seems to work for the most part though there are some issues im not sure how to resolve due to my inexperience with streaming. for example, trying to use audio causes panics with an if the stream loops, playback framerate seems to get worse and worse for some reason. perhaps i need to flush the decoders upon loop, but i would need a signal from ffmpeg to do that, assuming ffmpeg gets a packet telling it to loop the stream (but im not sure if thats a thing) duration doesn't need to be a value if the input if a udp stream, but what should this mean for seeking? we would need to buffer the frames to allow for seeking in the first place, but im not sure if seeking is even a thing that people want to do for udp streams; probably not, but correct me if im wrong. perhaps there should also be options to set the input packet buffer size as well as the "refresh rate". let me know what you think |
src/lib.rs
Outdated
@@ -707,10 +705,10 @@ impl Player { | |||
} | |||
} | |||
|
|||
let is_subtitle_cyclable = self.subtitle_stream_info.1 > 1; | |||
let is_audio_cyclable = self.audio_stream_info.1 > 1; | |||
let is_subtitle_cycleable = self.subtitle_stream_info.1 > 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe "cyclable" is the correct spelling, atleast per wiktionary
src/lib.rs
Outdated
} | ||
|
||
/// Create new [`Player`] streaming from socket UDP | ||
pub fn new_udp<T: ToSocketAddrs>(ctx: &egui::Context, socket: T) -> Result<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can rename this to from_udp
(i renamed new_from_bytes
to from_bytes
)
I will test it out with audio and see if I can find the error. Maybe the panic is caused if no audio channels is part of the stream.
Not something I've noticed. Is it noticeable after a short period of time (i.e. a couple of minutes)?
I think seeking can be skipped first since real-time streaming is more important imo. Later seeking could be enabled by buffering (up to some limit) and keeping track of the duration since first frame in buffer (calculated by using the streams fps).
Both could be a good idea. Would an UDP_option struct with a sensible Default as part of the |
it got worse with each loop for the files that i tested but ill try to test some different files in case it was something specific to those
sounds good
id think the socket address should be specified as a the function param of i like the options struct idea. i can consolidate all the other player options there too |
I changed the approach to use the new function and only change options that are different for udp. Should be much simpler to keep up to date. Changing some of the options specifically for udp streaming seemed to improve performance. I will investigate further and look at your other comments when I get time. UDP options are described here: https://www.ffmpeg.org/ffmpeg-protocols.html#udp Should I just keep the PR open or do you prefer another workflow? |
keeping it open is fine; thanks for all your work |
I think I've tracked down the problem with adding audio. Panic can be avoided by setting udp option New ProblemIn Possible solutions
What do you think? |
this makes sense. currently, streamers attempt to create their own input contexts so that "throwing away" packets isnt an issue. but for network streaming, they will share the same underlying udp context (unless the reason i went with the approach i did (rather than have centralized packet distribution) is that streamers consume packets at different rates at different intervals. there might be a video stream @ 10 frames/second while the audio stream is @ something more continuous and still a subtitle stream @ something more random. this on its own wouldnt be too bad, but in addition, decoders can get "full" with packets, needing to output a frame before accepting the next packet. ideally the code for file streaming would work the same as network streaming (solution 1). so in order to properly distribute packets between streamers, we would need to
some of the performance differences between each approach are not immediately obvious to me, so ill need to experiment and perform some benchmarks |
Fixed some spelling and added support for streaming video over socket.
Some solutions might be a little "hacky", e.g. framerate is set to 500 and used to check for new frames often and the actual framerate is used to "catch up" to the live portion of the stream by dropping frames.
The video is also set to start as part of new_udp() since it seemed more natural for streaming videos.
The feature can be tested using ffmpeg with the settings below.
Audio is untested.
Hopefully it can be of use.