n00kii/egui-video

Add subtitle support

Closed this issue · 11 comments

I tried to think of a way to create a pull request myself, but the subtitle decoder has a different api and it has this single function which takes a packet and a Subtitle buffer. Hence I cannot fit it in the Streamer trait. Any ideas on how to go about it? I know I have been troubling you a lot recently, but can you look into it?

Please and thank you.

I'll look into it. I might need to rewrite the streamer trait or figure out a way to read and buffer all the subtitle data at player instantiation.

I was trying out a crude solution to store the packet that was passed at send packet in the Player struct and tried to render that at the apply frame stage, But since there are no safe bindings to the underlying subtitle data, I was getting only empty strings and null pointers in the rect data. Notify me if you find something helpful.

I was experimenting with mkv videos embedded with ass subtitles.

hi there! sorry for the delay, first few weeks of semester are hectic.
i swam around in the source code until i found ffmpeg::codec::subtitle::Subtitle which seems to be what we needed. it seems the API for decoding video and audio frames has been changed/updated from what it was originally was, but the API for decoding subtitles stayed the same (Decoder::decode). putting that all together i made a very rough implementation for the subtitle support. i only have one video with subtitles to test on, so please checkout the branch subtitles and see if it works on your videos!

Yes, the subtitles display for sure. Thanks for putting in the effort. The videos I have been testing with have subtitles in the ass format which need further parsing and also the subtitles display at the middle right of the video. But I think I can look into these issues. I am currently a little bit swamped (I am actually a doctor and not a programmer by profession), But I will look into it and try to fix it. Thank you so much.

no problem! just skimming the ass spec, i think i might be able to make a very basic parser, though some things like \fn for selecting font name wont work unless that font has already been loaded into egui. but ill see what i can do for now

alright the baseline parser is complete. the only things that are currently being parsed are style overrides for position, primary text color, and alignment.

unfortunately, i am completely lost for figuring out how to load the style specific info from ffmpeg; either documentation doesnt exist (unlikely) or i just don't know what to search for. we are still missing alot of styling effects, many of which seem impossible to do in egui at the moment, but ill leave that to the future.

please test this out with your videos and let me know if you notice any critical issues

Sir you are an absolute legend. Thank you so much. It works!!!.

Now all this player requires is a way to switch between various audio and subtitle streams and then it will have all the features I need to replace mpv from my project. Thank you so much for all work.

#5 : I just create a pull request for stream cycling. Some subtitles are rendering weirdly though after I tested it with a lot of different videos, most of them seem to work fine.

thank you, i added a couple changes and merged that, gonna merge this one in now!

That is pretty neat. Thank you. Push the new version to crates.io wen you can.