FFMPEG生成的MPEG Dash输出不起作用

时间:2018-11-17 14:53:30

标签: ffmpeg streaming mpeg-dash

我使用ffmpeg创建了一个破折号输出sample_video.mpd文件,但是当我尝试使用破折号js播放该视频时,视频只是加载而已。 下面是生成的mpd文件

<?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="PT1M2.3S"
minBufferTime="PT20.0S">
<ProgramInformation>
</ProgramInformation>
<Period id="0" start="PT0.0S">
    <AdaptationSet id="0" contentType="video" segmentAlignment="true" bitstreamSwitching="true" lang="und">
        <Representation id="0" mimeType="video/mp4" codecs="avc1.640015" bandwidth="255520" width="426" height="240" frameRate="24/1">
            <SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="198656" d="69120" />
                    <S d="75264" />
                    <S d="174592" />
                    <S d="122880" />
                    <S d="125440" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
        <Representation id="2" mimeType="video/mp4" codecs="avc1.64001e" bandwidth="726596" width="854" height="480" frameRate="24/1">
            <SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="198656" d="69120" />
                    <S d="75264" />
                    <S d="174592" />
                    <S d="122880" />
                    <S d="125440" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
        <Representation id="4" mimeType="video/mp4" codecs="avc1.64001f" bandwidth="1433314" width="1280" height="720" frameRate="24/1">
            <SegmentTemplate timescale="12288" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="198656" d="69120" />
                    <S d="75264" />
                    <S d="174592" />
                    <S d="122880" />
                    <S d="125440" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
    </AdaptationSet>
    <AdaptationSet id="1" contentType="audio" segmentAlignment="true" bitstreamSwitching="true" lang="und">
        <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
            <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
            <SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="772096" d="270336" />
                    <S d="293888" />
                    <S d="681984" />
                    <S d="480256" />
                    <S d="492544" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
        <Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
            <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
            <SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="772096" d="270336" />
                    <S d="293888" />
                    <S d="681984" />
                    <S d="480256" />
                    <S d="492544" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
        <Representation id="5" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="341000" audioSamplingRate="48000">
            <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="6" />
            <SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="3">
                <SegmentTimeline>
                    <S t="772096" d="270336" />
                    <S d="293888" />
                    <S d="681984" />
                    <S d="480256" />
                    <S d="492544" />
                </SegmentTimeline>
            </SegmentTemplate>
        </Representation>
    </AdaptationSet>
</Period>

以下是我用来生成多比特率视频的ffmpeg命令

ffmpeg -y -i sample_video.mp4 ^
-c:v libx264 -x264opts "keyint=24:min-keyint=24:no-scenecut" -r 24 ^
-c:a aac -b:a 128k ^
-bf 1 -b_strategy 0 -sc_threshold 0 -pix_fmt yuv420p ^
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 ^
-b:v:0 250k  -filter:v:0 "scale=-2:240" -profile:v:0 baseline ^
-b:v:1 750k  -filter:v:1 "scale=-2:480" -profile:v:1 main ^
-b:v:2 1500k -filter:v:2 "scale=-2:720" -profile:v:2 high ^
sample_dash.mp4

并生成mpd文件

ffmpeg -y -re -i sample_dash.mp4 ^
-map 0 ^
-use_timeline 1 -use_template 1 -window_size 5 -adaptation_sets 
"id=0,streams=v id=1,streams=a" ^
-f dash sample_video.mpd

我还在chrome网络标签中看到只有init-stream4.m4s和init-stream5.m4s被调用。

1 个答案:

答案 0 :(得分:0)

您准备好使用ffmpeg + mp4box破折号打包程序了吗?我发现mp4box可以产生更好的细分+清单。

users

我总是使用破折号和CREATE TABLE公式使用audiorate(44100,48000)来给出段文件的持续时间。