FFMpeg 命令行创建特定的 MPEG-DASH 清单

FFMpeg 命令行创建特定的 MPEG-DASH 清单

我尝试获取 FFMpeg 命令以生成以下清单。下面是我尝试制作的 FFmpeg 命令,但它没有创建与我尝试从第三方系统复制流以将我自己的流添加到他们的系统以便实际播放相同的清单文件。

"$ffmpeg_path" \
    -i "$input_file" \
    -r 30000/1001 \
    -vf "scale=3840:1080" \
    -c:v libx265 \
    -c:a aac -b:a 128k \
    -ar 48000 \
    -f dash \
    -use_timeline 1 \
    -use_template 1 \
    -init_seg_name "init-stream\$RepresentationID\$.m4s" \
    -media_seg_name "chunk-stream\$RepresentationID\$-\$Number%05d\$.m4s" \
    -seg_duration 3 \
    "$output_file"

上述代码产生了一个结构如下的清单。

<?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="PT1M35.1S"
    maxSegmentDuration="PT3.0S"
    minBufferTime="PT16.8S">
    <ProgramInformation>
    </ProgramInformation>
    <ServiceDescription id="0">
    </ServiceDescription>
    <Period id="0" start="PT0.0S">
        <AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="30000/1001" maxWidth="3840" maxHeight="1080" par="32:9">
            <Representation id="0" mimeType="video/mp4" codecs="hev1" bandwidth="2227590" width="3840" height="1080" sar="1:1">
                <SegmentTemplate timescale="30000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="247247" />
                        <S d="250250" r="9" />
                        <S d="104104" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true">
            <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="48000">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1" />
                <SegmentTemplate timescale="48000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="143360" />
                        <S d="144384" r="29" />
                        <S d="93120" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

问题是我需要它来创建一个流,其中的清单看起来类似于下面的清单。如果它看起来或功能不像下面这样,它将无法在此第三方系统上正确播放。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT1M35.7S" minBufferTime="PT5.9S" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd">
    <ProgramInformation />
    <Period id="0" start="PT0.0S">
        <AdaptationSet id="0" contentType="video" segmentAlignment="true" bitstreamSwitching="true">
            <Representation id="0" bandwidth="12000000" width="3840" height="1080" frameRate="30000/1001" mimeType="video/mp4" codecs="hev1">
                <SegmentTemplate media="chunk-stream$RepresentationID$-$Number%05d$.m4s" initialization="init-stream$RepresentationID$.m4s" startNumber="1" timescale="30000">
                    <SegmentTimeline>
                        <S t="0" d="89089" r="31" />
                        <S d="21021" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="1" contentType="audio" segmentAlignment="true" bitstreamSwitching="true">
            <Representation id="1" bandwidth="1536000" audioSamplingRate="48000" mimeType="audio/mp4" codecs="mp4a.40.2">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="16" />
                <SegmentTemplate media="chunk-stream$RepresentationID$-$Number%05d$.m4s" initialization="init-stream$RepresentationID$.m4s" startNumber="1" timescale="48000">
                    <SegmentTimeline>
                        <S t="0" d="143360" />
                        <S d="142336" r="2" />
                        <S d="143360" />
                        <S d="142336" r="3" />
                        <S d="143360" />
                        <S d="142336" r="3" />
                        <S d="143360" />
                        <S d="142336" r="3" />
                        <S d="143360" />
                        <S d="142336" r="3" />
                        <S d="143360" />
                        <S d="142336" r="3" />
                        <S d="143360" />
                        <S d="142336" r="1" />
                        <S d="32768" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

相关内容