I'm trying to live stream H.264 content to HTML5 using the media source extensions API.
The following method works pretty well:
ffmpeg -i rtsp://10.50.1.29/media/video1 -vcodec copy -f mp4 -reset_timestamps 1 -movflags frag_keyframe+empty_moov -loglevel quiet out.mp4
and then:
mp4box -dash 1000 -frag 1000 -frag-rap out.mp4
I can take the MP4Box output (out_dashinit.mp4
) and send it through Web Sockets, chunk by chunk, to a JavaScript client that feeds it to the media source API.
However, this is not a good method for live content.
What I'm trying to do now, is to create a single pipeline in order to do it in realtime and with the minimum possible latency.
With FFmpeg it's possible to redirect the output to stdout
instead of out.mp4
and grab the content.
I couldn't figure out if it's possible to combine MP4Box into the pipeline.
- Can MP4Box take the input data from a source which is not a file?
- Can MP4Box grab such a content progressively (either from a file or other source) while it is arriving in realtime? i.e. wait a little if stream stops for 1 sec and resume automatically.
- Same question but for the output: can it output to something which is not a file (such as
stdout
) and can it do so progressively so that whenever output data is ready, I will be able to take it and transfer it to the web client, essentially generating a never-ending dashed MP4.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…