0

我正在使用以下命令,之前放在这里:生成 DASH 文件:

ffmpeg -y -nostdin -loglevel error -i "$1" \
        -map 0:v:0  -map 0:v:0 -map 0:v:0  -map 0:v:0  -map 0:v:0  -map 0:v:0 -map 0:a\?:0  \
        -maxrate:v:0 350k -bufsize:v:0 700k -c:v:0 libx264 -filter:v:0 "scale=320:-2"  \
        -maxrate:v:1 1000k -bufsize:v:1 2000k -c:v:1 libx264 -filter:v:1 "scale=640:-2"  \
        -maxrate:v:2 3000k -bufsize:v:2 6000k -c:v:2 libx264 -filter:v:2 "scale=1280:-2" \
        -maxrate:v:3 300k -minrate:v:3 100k -bufsize:v:3 600k -c:v:3 libvpx-vp9 -filter:v:3 "scale=320:-2"  \
        -maxrate:v:4 1088k -minrate:v:4 200k -bufsize:v:4 2176k -c:v:4 libvpx-vp9 -filter:v:4 "scale=640:-2"  \
        -maxrate:v:5 1500k -minrate:v:5 300k -bufsize:v:5 3000k -c:v:5 libvpx-vp9 -filter:v:5 "scale=1280:-2"  \
        -use_timeline 1  -use_template 1 -adaptation_sets "id=0,streams=0,1,2 id=1,streams=3,4,5 id=2,streams=a" \
        -threads 8 -crf 3 -seg_duration 5 -hls_init_time 1 -hls_time 5 -hls_playlist true -f dash "$2"

问题是,在输出中,对于 vp9 编解码器,我总是获得 200k 的带宽(请参见下面的输出),而对于 h264 编解码器的相同视频带宽随着标准分辨率的不同而变化,而且相当少,我希望 vp9 压缩更多,甚至更少. 我已经使用多个不同的选项进行了测试,例如:、、、-b:v等,但使用这些不同的值无法正常工作,我错过了什么?-deadline-cpu-used -crf

示例输出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="PT25.4S"
    minBufferTime="PT15.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.64000c" bandwidth="104972" width="320" height="180" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="130130" />
                        <S d="250250" />
                        <S d="176176" />
                        <S d="54054" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="1" mimeType="video/mp4" codecs="avc1.64001e" bandwidth="227233" width="640" height="360" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="130130" />
                        <S d="250250" />
                        <S d="180180" />
                        <S d="50050" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="2" mimeType="video/mp4" codecs="avc1.64001f" bandwidth="616878" width="1280" height="720" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="130130" />
                        <S d="250250" />
                        <S d="180180" />
                        <S d="50050" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="1" contentType="video" segmentAlignment="true" bitstreamSwitching="true" lang="und">
            <Representation id="3" mimeType="video/mp4" codecs="vp09.00.11.08" bandwidth="200000" width="320" height="180" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128128" r="3" />
                        <S d="98098" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="4" mimeType="video/mp4" codecs="vp09.00.21.08" bandwidth="200000" width="640" height="360" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128128" r="3" />
                        <S d="98098" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
            <Representation id="5" mimeType="video/mp4" codecs="vp09.00.31.08" bandwidth="200000" width="1280" height="720" frameRate="24000/1001">
                <SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="128128" r="3" />
                        <S d="98098" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet id="2" contentType="audio" segmentAlignment="true" bitstreamSwitching="true" lang="eng">
            <Representation id="6" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="44100">
                <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
                <SegmentTemplate timescale="44100" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
                    <SegmentTimeline>
                        <S t="0" d="235520" r="3" />
                        <S d="180224" />
                    </SegmentTimeline>
                </SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

我正在使用这个视频,但我尝试过的所有约 30 秒的视频都是一样的。

4

1 回答 1

0

从这个答案中获得帮助,看来我必须使用两次编码或恒定质量编码。

当我使用 恒定质量编码时,我删除了bufSize,minRate等并将其设置-b:v为零,我能够生成不默认为 200k 的可变比特率,下面的示例命令,我也将使用 两遍编码进行测试。

ffmpeg -y -nostdin -loglevel error -i "$1" \
        -map 0:v:0  -map 0:v:0 -map 0:v:0  -map 0:v:0  -map 0:v:0  -map 0:v:0 -map 0:a\?:0  \
        -maxrate:v:0 350k -bufsize:v:0 700k -c:v:0 libx264 -filter:v:0 "scale=320:-2"  \
        -maxrate:v:1 1000k -bufsize:v:1 2000k -c:v:1 libx264 -filter:v:1 "scale=640:-2"  \
        -maxrate:v:2 3000k -bufsize:v:2 6000k -c:v:2 libx264 -filter:v:2 "scale=1280:-2" \
        -b:v:3 0 -c:v:3 libvpx-vp9 -filter:v:3 "scale=320:-2"  \
         -b:v:4 0 -c:v:4 libvpx-vp9 -filter:v:4 "scale=640:-2"  \
         -b:v:5 0 -c:v:5 libvpx-vp9 -filter:v:5 "scale=1280:-2"  \
        -use_timeline 1  -use_template 1 -adaptation_sets "id=0,streams=0,1,2 id=1,streams=3,4,5 id=2,streams=a" \
        -threads 32 -deadline best -cpu-used 1 -crf 3 -seg_duration 5 -hls_init_time 1 -hls_time 5 -hls_playlist true -f dash "$2"
于 2019-11-29T04:12:30.247 回答