mbebenita / Broadway

A JavaScript H.264 decoder.
Other
2.73k stars 424 forks source link

add support for main profile #189

Open vinnitu opened 6 years ago

vinnitu commented 6 years ago

Is it possible to add support for other types of h264 profiles? I have stable main profile and cannot change it ((

I don't know if original decoder from android supports it?

yahsaves commented 6 years ago

AFIK adding support for the main profile would require a rebuild/modification of the source android decoder.

The problem with the "main" profile is it's use of P frames, which this decoder doesn't support (at least the wasm build).

A question I have is what are you trying to use Broadway to do? I would imagine Broadway would be used to have full playback control over a video/custom memory management of rendering the frames/real time streaming.

If that is the case couldn't you process your mp4 files ahead of time with the ffmpeg command mentioned in the documentation?

Outside of that 99%+ of browsers support mp4 for standard playback. A little more context may have solve your problem.

soliton4 commented 6 years ago

i took over maintaining this project a couple of years ago and so far i just updated it to keep it working with latest browsers and emscripten.

i could completely redo the decoder part and include an openh264 > js build to support main profile and even more features. it would make sense to do that as broadway2 or some other name under my own github. i wonder how the community would react to such a move.

also i am not completely confident about my mp4 parsing skills. if someone could contribute with knowledge about how to parse mp4 files that would help a lot.

mbalieiro commented 5 years ago

Please @mbebenita is there any chance you add support for the main profile? Or is there a way that I could add this support for my self? (where could I start?) Please Please, your implementation is superb and work perfectly for my needs but some of my live streams are in Main profile. Help me please.

soliton4 commented 5 years ago

im afraid @mbebenita is not actively maintaining this project. i pretty much took over that task. perhaps i should host it on my github and put a forward in here. anyway. the c sources for broadway dont support main profile so simply adding support for main is not that easy. you can however compile openh264 to js and there are even a few projects on git that did that. it will give you a wide area of supported features including main profile. the downside is that it is considerably slower than broadway. thats also the reason we havent switched to those sources already

mbalieiro commented 5 years ago

Thanks @soliton4, I'm trying right now to compile the openh264 but I think it will be very slow (in my research I see some solutions that was slow indeed). Did you know what is the magic mbebenita made to gain that speed? If it was hand optimization then there is hope for me ;-) I need to show up to 24 individual low res (704x480) h264 Main Profile stream. Do you have a clue on how can I do this without MSE (witch the buffer architecture sucks and prevents me to deal with poor quality network)? Do you know if is there any chance of using SIMD instruction set in javascript? (WebCL is a reality or just a distant future?) Is there a way or project that allow the use of gpu hardware to decode h264 (dxva i.e.) in javascript? Sorry for these so many questions. I'm still a noob :D

paperspaceBen commented 5 years ago

well you can always use a video tag. that will work in most cases to decode your mp4 files. its hard to use for streaming thou and latency is terrible

there was a bit of optimization but its mostly the fact that openh264 is a huge code base and broadway uses c sources from the android project. its a very lean aproach to decoding. best solution would probably to not encode the video in main in the first place. or split the video in 4 and use 4 instances of the js decoder. that will at least make use of multiple cpu cores. there is also slicing but that is very hard to get working in js

paperspaceBen commented 5 years ago

oops github account mixup. i am soliton4 just logged in as a different account ;)

huangfe commented 4 years ago

@soliton4 add support for main profile???