我之前已使用以下 ffmpeg 命令成功制作了 mpeg-dash 清单:
ffmpeg -i input.webm -c:v copy -c:a copy -f dash -seg_duration 15 manifest.mpd
是经过编码的视频input.webm
文件,因此无需重新编码。因此我只需复制两个流即可。VP9
opus
现在,我正在尝试为那些不支持 VP9 和/或 opus 的设备向此清单添加一个适配集,使用以下命令(为便于阅读添加了换行符):
ffmpeg -i input.webm
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0
-c:v:0 copy
-c:a:0 copy
-c:v:1 libx264 -b:v:1 1000k
-c:a:1 aac -b:a:1 128k
-adaptation_sets "id=0,streams=v id=1,streams=a" -f dash -seg_duration 15 manifest.mpd
ffmpeg 似乎同意了我的意见,并输出了我所期望的内容,即与上一个命令相同的文件以及类似于 mp4 和 aac 块的其他文件。但是我的带有 dash.js 的网站不接受此清单,视频不再播放。此外,dash.js 不会在浏览器控制台中产生任何错误。我做错了什么?
显现:
<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:dash:schema:mpd:2011"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
profiles="urn:mpeg:dash:profile:isoff-live:2011"
type="static"
mediaPresentationDuration="PT46.7S"
maxSegmentDuration="PT15.0S"
minBufferTime="PT40.0S">
<ProgramInformation>
</ProgramInformation>
<ServiceDescription id="0">
</ServiceDescription>
<Period id="0" start="PT0.0S">
<AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="25/1" maxWidth="1920" maxHeight="1080" par="16:9">
<Representation id="0" mimeType="video/webm" codecs="vp09.00.40.08" bandwidth="713" width="1920" height="1080" scanType="unknown" sar="1:1">
<SegmentTemplate timescale="1000" initialization="init-stream$RepresentationID$.webm" media="chunk-stream$RepresentationID$-$Number%05d$.webm" startNumber="1">
<SegmentTimeline>
<S t="92" d="19200" r="1" />
<S d="8320" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.640028" bandwidth="1000000" width="1920" height="1080" sar="1:1">
<SegmentTemplate timescale="12800" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="1024" d="244736" />
<S d="256000" />
<S d="97280" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true">
<Representation id="1" mimeType="audio/webm" codecs="opus" bandwidth="96" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
<SegmentTemplate timescale="1000" initialization="init-stream$RepresentationID$.webm" media="chunk-stream$RepresentationID$-$Number%05d$.webm" startNumber="1">
<SegmentTimeline>
<S t="80" d="15001" />
<S d="15000" r="1" />
<S d="1757" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
<SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="3152" d="720920" />
<S d="720896" r="1" />
<S d="81920" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
</MPD>
答案1
必须AdaptationSet
包含比特率变体流(Representations
)一个编解码器仅。在您发布的示例 MPD 中,视频适配集包含 VP9 和 H.264 视频流的变体。
(这是因为当你id=0,streams=v
在 FFMPEG 中使用语法时,它会把全部将您的视频流合并到一个适配集中。
我还没有测试过,但是将 ffmpeg 命令的最后一行更改为类似这样的内容应该会让每个编解码器都获得自己的适配集:
-adaptation_sets "id=0,streams=0 id=1,streams=1 id=2,streams=2 id=3,streams=3" -f dash -seg_duration 15 manifest.mpd