duanyao / codecbox.js

video and audio codecs for javascript based on ffmpeg and asm.js
Other
28 stars 12 forks source link

is possible to add chunks instead entire file? #7

Open publicocean0 opened 7 years ago

publicocean0 commented 7 years ago

how to pass chunks to fmpeg ?

duanyao commented 7 years ago

What is the concrete use case?

FFmpeg supports "concat:" protocol, which plays multiple URLs in sequence. Maybe codecbox.js can handle it if "concat:" protocol is enabled (not tried yet). However it seems the list of URLs has to be specified on start (i.e. not on the fly).

If each chunk is playable on its own, I think it is also possible to do a concatenated playback with multiple CodecBoxDecoder instances. If not, I also have a hard time to figure out how to handle it. FFmpeg supports HTTP Live Stream, but I still have no idea how to enable HTTP in emscripten.

publicocean0 commented 7 years ago

no, chunks are parts of a single long video. I think the challenge it here. Because video/audio for his nature a stream not blob. In many real case to load a video as blob can create a crash of a mobile browser for out of memory. This feature will permit to solve all problems about incompatibility for browsers. I developped a player using mse (html5 tecnology using chunks) . Really there are many other making the same thing. First at all shaka player. It works in all browsers except safari and ie. My idea was do developer the MediaSource object in js using ffmpeg. In this way in all browsers will be possible to work in the same way in any context (dash or hls or other custom solutions). it will be the end of a hell for developers. Anyway i want help you for understanding if we can receive a help from ffmpeg team for a free support for doing it.

it i understood correctly you use a specific function of the ffmpeg library for passing the entire file. and you receive frames. we have to find another function in the decoder for passing little chunks instead of file.

duanyao commented 7 years ago

I think we need to replace the http component of ffmpeg with a wrapper of XHR, and HLS should work.

publicocean0 commented 7 years ago

I realized for a my internal project a generic javascript prototype class for receiving stream, either with ajax , either with file from local , either with websocket ... or other data source. It would be a generic solution for developers. i can also pass the implementation of this prototype for local file. Eventually we can implement version for ajax , it is the most used in a server, but the abstraction permits to working also for other dat source. I used it for testing my works before to use in a server. I can release this code freely if can be usefull for realizing a good and generic solution for all

duanyao commented 7 years ago

FFmpeg's IO is synchronous for both local files and network, as oppose to most IO APIs of the Web platform. Asynchronous APIs can not be a drop-in replacement of synchronous ones, so non-trivial part of FFmpeg's IO modules have to be rewritten(in C/C++) to adapt the Web platform. This is why this still has not happened (it is definitely doable, through). Blob is OK because there is a FileReaderSync, but synchronous XHR can only handle text data.

publicocean0 commented 7 years ago

uffff