使用 mp4box 实时流式传输破折号内容 [英] Live streaming dash content using mp4box

查看:27
本文介绍了使用 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 将其逐块发送到 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. 同样的问题,但对于输出:它可以输出到不是文件的东西(例如 stdout)并且它可以逐步这样做,以便每当输出数据准备好时,我将能够将其传输到网络客户端,从而生成一个永无止境的破折号 MP4.
  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.

基本上,您将生成带有 H264fMP4,并将 moov 框发送到浏览器以进行初始化和 moof您生成的每个 MP4 片段的 +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.

请务必使用可用的最新版本.

Be sure to use the latest version available.

这篇关于使用 mp4box 实时流式传输破折号内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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