用于HTML5的FFMPEG H.264编码(最终是MPEG-DASH) [英] FFMPEG H.264 encoding for HTML5 (and ultimately MPEG-DASH)

查看:404
本文介绍了用于HTML5的FFMPEG H.264编码(最终是MPEG-DASH)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将MP4文件转换为能够通过 Chrome上的> DASH-IF HTML5播放器。我使用FFMPEG和MP4Box(来自GPAC)对视频进行转码,然后将其拆分,并在JavaScript控制台上不断收到MEDIA_ERR_SRC_NOT_SUPPORTED错误。

I want to convert an MP4 file to an MPEG-DASH video capable of being played through the DASH-IF HTML5 player on Chrome. I use FFMPEG and MP4Box (from GPAC) to transcode the video and then split it, and keep getting a MEDIA_ERR_SRC_NOT_SUPPORTED error on the JavaScript console.

从(非常稀疏)在线提供的信息(请参见此Chromium线程),好像Chrome本身仅支持带有受约束的基线编码配置文件的MP4文件,并且对仅支持 avc1.42E01E,mp4a.40.2编解码器非常严格。

From the (very sparse) information available online (see this Chromium thread), it would appear as though Chrome natively only supports MP4 files with the Constrained Baseline encoding profile, and is very strict on only supporting the "avc1.42E01E,mp4a.40.2" codecs.

I在使用MP4Box进行分割之前,我已经尝试了使用FFMPEG从命令行对视频进行编码的几乎所有方法,从而获得了编解码器配置文件 avc1.42E01E的H.264视频编码,但是它始终为我提供 avc1。 42C01E。这是我尝试过的(许多)FFMPEG命令之一:

I have tried pretty much everything I can to encode the video from the command line, prior to splitting with MP4Box, with FFMPEG to get an H.264 video encoding with codec profile "avc1.42E01E", but it just keeps giving me "avc1.42C01E". Here's one of the (many) FFMPEG commands I've tried:

ffmpeg -y -i Sintel_-_Third_Open_Movie_by_Blender_Foundation.mp4 -profile:v baseline -level:v 30 -acodec libvo_aacenc -vcodec libx264 sintel-recoded.mp4

根据在ITU-T标准第7.4.2.1.1节和A2.1-A2.3节中,视频编码 avc1.42E01E表示约束标志为0xE0(已设置constraint_set标志0、1和2),而 avc1 .42C01E表示约束标志为0xC0(已设置constraint_set标志0和1)。前者(0xE0)表示符合Baseline,Main和Extended配置文件,而后者(0xC0)表示仅符合Baseline和Main配置文件。

According to the ITU-T standard, sections 7.4.2.1.1 and A2.1-A2.3, a video encoding of "avc1.42E01E" implies constraint flags of 0xE0 (constraint_set flags 0, 1 and 2 are set), whereas "avc1.42C01E" implies constraint flags of 0xC0 (constraint_set flags 0 and 1 are set). The former (0xE0) implies conformance to the Baseline, Main and Extended profiles, whereas the latter (0xC0) implies conformance to only the Baseline and Main profiles.

显然,FFMPEG不支持H.264的扩展配置文件。

Apparently, FFMPEG doesn't support the Extended profile for H.264.

是否有人对如何将MP4文件编码为 avc1.42E01E有任何建议?理想情况下使用FFMPEG,但是我愿意使用其他编码器吗?

Does anyone perhaps have any advice as to how to encode an MP4 file as "avc1.42E01E"? Ideally with FFMPEG, but I am open to using other encoders?

推荐答案

在网上搜索了很长一段时间后,像 GitHub 这样的几个地方,我发现了问题是我在使用MP4Box分段之前没有分离音频和视频

After digging around online for ages, and asking questions in a few places like GitHub, I found that part of the problem was that I wasn't separating my audio and video prior to segmenting with MP4Box:

# transcode the video to "avc1.42c00d,mp4a.40.2"
ffmpeg -i Sintel_-_Third_Open_Movie_by_Blender_Foundation.mp4 -c:v libx264 -c:a libvo_aacenc -profile:v baseline -level:v 13 -g 250 -r 25 -keyint_min 250 -strict experimental -b:a 96k sintel.mp4

# copy out the video only
ffmpeg -i sintel.mp4 -c:v copy -an sintel-video.mp4

# copy out the audio only
ffmpeg -i sintel.mp4 -c:a copy -vn sintel-audio.mp4

# create the MPD manifest with MP4Box, but only with onDemand profile
MP4Box -dash 10000 -profile dashavc264:onDemand -out sintel.mpd sintel-audio.mp4 sintel-video.mp4

播放在Chrome 40.x中使用dash.js播放器就可以了。麻烦的是,它对于 live MP4Box配置文件(每个段具有单独的M4S文件)不起作用,但至少是一个开始。

Plays just fine in Chrome 40.x with the dash.js player. Trouble is, it doesn't work for the live MP4Box profile (with separate M4S files for each segment), but it's at least a start.

编辑:从那时起,我在使用castLabs的 DASH.encrypt实用程序。有关如何使用该实用程序的详细信息,请参见 Wiki条目。不幸的是,仍然无法通过MP4Box将我的内容DASH。

Edit: I've since had a lot more success with preparing and fragmenting my content using castLabs' DASH.encrypt utility. See the wiki entries for details on how to make use of the utility. Still haven't managed to get my content DASH'd with MP4Box unfortunately.

这篇关于用于HTML5的FFMPEG H.264编码(最终是MPEG-DASH)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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