将FFMPEG编码为MPEG-DASH或具有关键帧集群的WebM - 用于MediaSource API [英] Encoding FFMPEG to MPEG-DASH – or WebM with Keyframe Clusters – for MediaSource API

查看:206
本文介绍了将FFMPEG编码为MPEG-DASH或具有关键帧集群的WebM - 用于MediaSource API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向Chrome发送视频流,通过MediaSource API播放。

I'm currently sending a video stream to Chrome, to play via the MediaSource API.

据了解,MediaSource仅支持MPEG4编码的MP4文件, DASH或具有以关键帧开头的集群的WebM文件(否则会引发错误:媒体分段未以关键帧开始)。

As I understand it, MediaSource only supports MP4 files encoded with MPEG-DASH, or WebM files that have clusters beginning with keyframes (otherwise it raises the error: Media segment did not begin with keyframe).

是否有任何方式在MPEG -DFP或关键帧WebM格式与FFMPEG实时?

Is there any way to encode in MPEG-DASH or keyframed WebM formats with FFMPEG in real-time?

编辑:

我只是尝试使用 ffmpeg ... -f webm -vcodec vp8 -g 1 ,以便每个框架都是一个关键帧。不是理想的解决方案。现在它与MediaStream有效。使用WebM中的关键帧同步段的任何方式,所以不是每一帧都是关键帧?

I just tried it with ffmpeg ... -f webm -vcodec vp8 -g 1 so that every frame is a keyframe. Not the ideal solution. It does work with MediaStream now though. Any way to sync up the segments with the keyframes in WebM so not every frame needs to be a keyframe?

WebM / MP4和MediaSource的参考问题:

Media Source Api不适用于自定义的webm文件(Chrome版本23.0.1271.97 m )

MediaSource API和mp4

推荐答案

目前,FFMPEG不支持DASH编码。您可以使用FFMPEG进行细分( https://www.ffmpeg.org/ ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment ),但我建议结合FFMPEG和MP4Box。使用FFMPEG转码您的实况视频,然后MP4Box进行分段并创建.mpd索引。

At the moment FFMPEG does not support DASH encoding. You can segment with FFMPEG (https://www.ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment), but I recommend combining FFMPEG and MP4Box. Use FFMPEG to transcode your live video, and then MP4Box to segment and create the .mpd index.

MP4Box是GPAC的一部分( http://gpac.wp.mines-telecom.fr/ )。

MP4Box is a part of GPAC (http://gpac.wp.mines-telecom.fr/).

这是一个使用h264的例子:

Here is an example using h264:

ffmpeg -threads 4 -f v4l2 -i  /dev/video0 -acodec libfaac -ar 44100 -ab 128k -ac 2 -vcodec libx264 -r 30 -s 1280x720  -f mp4 -y "$movie" > temp1.mp4 && MP4Box -dash 10000 -frag 1000 -rap "$movie"

如果您需要VP8(WebM)使用: -vcodec libvpx -f webm -f ts

If you need VP8 (WebM), use: -vcodec libvpx and -f webm or -f ts.

这篇关于将FFMPEG编码为MPEG-DASH或具有关键帧集群的WebM - 用于MediaSource API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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