使用mp4box播放直播短片内容 [英] Live streaming dash content using mp4box

查看:223
本文介绍了使用mp4box播放直播短片内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用媒体源扩展程序API将 H.264 内容直播 HTML5

I'm trying to live stream H.264 content to HTML5 using the media source extensions API.

以下方法工作得很好:

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

然后:
mp4box -dash 1000 -frag 1000 -frag-rap out.mp4

我可以使用 MP4Box 输出( out_dashinit.mp4 ),并通过Web Sockets(chunk by chunk)发送给一个JavaScript客户端,将其提供给媒体源API。

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.

我现在要做的是创建一条管道,以便以实时和尽可能最小的延迟。
使用FFmpeg可以将输出重定向到 stdout 而不是 out.mp4 并获取内容。
我无法确定是否可以将MP4Box组合到管道中。

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.


  1. MP4Box可以从源不是文件?

  2. MP4Box可以在实时到达时逐渐获取这样的内容(来自文件还是其他来源)?即等待一点,如果流停止1秒钟并自动恢复。

  3. 同样的问题,但输出:它可以输出到不是文件的东西(如$ code > stdout ),并且它可以逐步进行,以便每当输出数据准备就绪时,我将能够将其传输到Web客户端,基本上生成一个永无止境的虚拟MP4。 li>
  1. Can MP4Box take the input data from a source which is not a file?
  2. 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.
  3. 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.


推荐答案

您不需要 MP4Box 来生成所需的输出,但是,您需要自行查找内容,才能在生成的文件中查找框。

You don't need MP4Box to generate the required output, but you'll need to chunk the content yourself looking for boxes in the generated file.

基本上,您将生成一个 fMP4 H264 ,并将您的MP4的每个片段的 moov 框发送给您的初始化和 moof + mdat 生成。您必须使用JavaScript编写播放器,您可能无法使用标准的DASH播放器。

Basically you'll generate an fMP4 with H264, and send to the browser the moov box for initialization and the moof+mdat boxes for each fragment of MP4 that you generate. You'll have to code the player in JavaScript, you probably won't be able to use a standard DASH player.

为了生成正确的碎片MP4,您需要传递给ffmpeg: -movflags empty_moov + omit_tfhd_offset + frag_keyframe + default_base_moof

To generate the correct fragmented MP4, you need to pass this to ffmpeg: -movflags empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof.

请确保使用最新版本。

这篇关于使用mp4box播放直播短片内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆