Html html5 视频标签编解码器属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16363167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
html5 video tag codecs attribute
提问by user2302694
I am trying to specify a specific video/audio codec in the video tag using
我正在尝试使用在视频标签中指定特定的视频/音频编解码器
<video poster="movie.jpg" controls>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'/>
<p>This is fallback content</p>
</video>
but can't find the right codecs statement to play the video , i have downloaded a video analyser and can see that its an avc1 and can see that the audio map.40.2 but can work out the rest of the codec, what does the 4d401e mean in the above ?
但找不到正确的编解码器语句来播放视频,我已经下载了一个视频分析器,可以看到它是一个 avc1 并且可以看到音频 map.40.2 但可以计算出编解码器的其余部分,4d401e 是什么上面的意思是?
Cheers Toby
干杯托比
回答by mark4o
The codecs
parameter is specified by RFC 6381. Specifically, see section 3.3for the meaning of avc1
and mp4a
values.
该codecs
参数由RFC 6381指定。具体而言,请参阅第 3.3 节以了解avc1
和mp4a
值的含义。
In the case of avc1.4D401E
, avc1
indicates H.264 video, and this is followed by a dot and three 2-digit hexadecimal numbers defined by the H.264 standard:
对于avc1.4D401E
,avc1
表示 H.264 视频,后面跟着一个点和三个H.264 标准定义的 2 位十六进制数:
profile_idc
- the byte containing the
constraint_set
flags (currentlyconstraint_set0_flag
throughconstraint_set5_flag
, and thereserved_zero_2bits
) level_idc
profile_idc
- 包含
constraint_set
标志的字节(当前constraint_set0_flag
通过constraint_set5_flag
, 和reserved_zero_2bits
) level_idc
Some examples:
一些例子:
avc1.42E01E
: H.264 Constrained Baseline Profile Level 3avc1.4D401E
: H.264 Main Profile Level 3avc1.64001E
: H.264 High Profile Level 3
avc1.42E01E
: H.264 约束基线配置文件级别 3avc1.4D401E
: H.264 主要配置文件级别 3avc1.64001E
: H.264 High Profile Level 3
These are also the second, third, and fourth bytes of the Sequence Parameter Set and the AVC Configuration Box in an MP4 file. You can dump these bytes using a program such as mp4file
: mp4file --dump movie.mp4
. Look for the avcC
(AVC Configuration) Box and the hexadecimal values for AVCProfileIndication
, profile_compatibility
, and AVCLevelIndication
.
这些也是 MP4 文件中序列参数集和 AVC 配置框的第二、第三和第四个字节。您可以使用诸如mp4file
: 之类的程序转储这些字节mp4file --dump movie.mp4
。认准avcC
(AVC配置)箱,为十六进制值AVCProfileIndication
,profile_compatibility
和AVCLevelIndication
。
As for mp4a.40.2
, mp4a
indicates MPEG-4 audio. It is followed by a dot and a hexadecimal ObjectTypeIndication
(objectTypeId
in mp4file
output), which can be looked up on the MPEG4 registration site. If this hexadecimal value is 40
(ISO/IEC 14496-3 Audio), it is followed by another dot and an audio object type in decimal. These are listed in the ISO/IEC 14496-3 standard and on Wikipedia, and correspond to the first 5 bits of the DecoderSpecificInfo
(decSpecificInfo
) (unless these bits equal 31, in which case add 32 to the next 6 bits). mp4a.40.2
indicates AAC LC audio, which is what is usually used with H.264 HTML5 video.
至于mp4a.40.2
,mp4a
表示 MPEG-4 音频。后跟一个点和一个十六进制ObjectTypeIndication
(objectTypeId
在mp4file
输出中),可以在 MPEG4 注册站点上查找。如果此十六进制值是40
(ISO/IEC 14496-3 音频),则后跟另一个点和十进制的音频对象类型。这些列在 ISO/IEC 14496-3 标准和维基百科上,对应于DecoderSpecificInfo
( decSpecificInfo
)的前 5 位(除非这些位等于 31,在这种情况下,将 32 添加到接下来的 6 位)。 mp4a.40.2
表示 AAC LC 音频,通常用于 H.264 HTML5 视频。
For example, codecs="avc1.42E01E, mp4a.40.2"
would be correct for the movie below:
例如,codecs="avc1.42E01E, mp4a.40.2"
对于下面的电影来说是正确的:
$ mp4file --dump movie.mp4
...
type avcC (moov.trak.mdia.minf.stbl.stsd.avc1.avcC) ?━━ avc1
configurationVersion = 1 (0x01)
AVCProfileIndication = 66 (0x42) ?━━ 42
profile_compatibility = 224 (0xe0) ?━━ E0
AVCLevelIndication = 30 (0x1e) ?━━ 1E
...
type esds (moov.trak.mdia.minf.stbl.stsd.mp4a.esds) ?━━ mp4a
version = 0 (0x00)
flags = 0 (0x000000)
ESID = 2 (0x0002)
streamDependenceFlag = 0 (0x0) <1 bits>
URLFlag = 0 (0x0) <1 bits>
OCRstreamFlag = 0 (0x0) <1 bits>
streamPriority = 0 (0x00) <5 bits>
decConfigDescr
objectTypeId = 64 (0x40) ?━━ 40
streamType = 5 (0x05) <6 bits>
upStream = 0 (0x0) <1 bits>
reserved = 1 (0x1) <1 bits>
bufferSizeDB = 0 (0x000000) <24 bits>
maxBitrate = 78267 (0x000131bb)
avgBitrate = 78267 (0x000131bb)
decSpecificInfo
info = <2 bytes> 11 90 |..| ?━━ 2 (first 5 bits in decimal)
...
回答by BaskingShark
mark4o gives by far the best explanation I've seen of how to decipher codec information. Excellent.
mark4o 给出了迄今为止我所见过的关于如何破译编解码器信息的最佳解释。优秀。
One piece which may require a little more detail is how to break out the specific audio object type from the decSpecificInfo value. Finding the "mp4a.40" part is very clear, the ".2" section can be a little tricky.
一个可能需要更多细节的部分是如何从 decSpecificInfo 值中分离出特定的音频对象类型。找到“mp4a.40”部分很清楚,“.2”部分可能有点棘手。
We start with a sequence of single byte hexadecimal values: "11 90" in mark4o's example or "12 08" in my case. Both of those are a total of 2 bytes... there may be more values but only the first 2 matter for finding the object type (and usually only the first byte). We're looking for individual bits so convert each digit in the hexadecimal values to binary; there should be 4 binary digits for each hexadecimal digit. Take the first 5 binary digits — 4 from the first hex digit, 1 from the next — and convert that binary value to decimal. Here are the steps:
我们从一系列单字节十六进制值开始:mark4o 示例中的“11 90”或我的示例中的“12 08”。这两个总共有 2 个字节......可能有更多的值,但只有前 2 个对于查找对象类型很重要(通常只有第一个字节)。我们正在寻找单个位,因此将十六进制值中的每个数字转换为二进制;每个十六进制数字应该有 4 个二进制数字。取前 5 个二进制数字——4 个来自第一个十六进制数字,1 个来自下一个——并将该二进制值转换为十进制。以下是步骤:
Example 1 (11 90):
Starting value: 11 90
Separate the hex digits: 1 1 9 0
Convert each digit to binary: 0001 0001 1001 0000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
Example 2 (12 08):
Starting value: 12 08
Separate the hex digits: 1 2 0 8
Convert each digit to binary: 0001 0010 0000 1000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
They are the same object type in spite of having different decSpecificInfo values.
尽管具有不同的 decSpecificInfo 值,但它们是相同的对象类型。
回答by Cenk Alti
You can use MP4Boxtool to find out codec strings in RFC6381 format. Still you have to join them with commas.
您可以使用MP4Box工具查找 RFC6381 格式的编解码器字符串。你仍然必须用逗号加入它们。
You can use this command:
你可以使用这个命令:
MP4Box -info big.mp4 2>&1 | grep RFC6381 | awk '{print $4}' | paste -sd , -
MP4Box -info big.mp4 2>&1 | grep RFC6381 | awk '{print $4}' | paste -sd , -