我正在使用 mpeg dash 对来自我的服务器的视频进行自适应比特率流传输。
我使用 ffmpeg 和 MP4Box 从我的源 .mp4 生成 4 个不同质量的视频文件
生成的 .mpd 文件具有以下代码
<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.5.1-DEV-rev5619 on 2015-07-14T11:07:18Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500000S" type="static" mediaPresentationDuration="PT0H3M1.42S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011">
<ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
<Title>test/test.mpd generated by GPAC</Title>
</ProgramInformation>
<Period duration="PT0H3M1.42S">
<AdaptationSet segmentAlignment="true" maxWidth="1920" maxHeight="1080" maxFrameRate="24" par="16:9" lang="und" subsegmentStartsWithSAP="1">
<Representation id="1" mimeType="video/mp4" codecs="avc1.64000d" width="320" height="240" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="375715">
<BaseURL>400_dashinit.mp4</BaseURL>
<SegmentBase indexRangeExact="true" indexRange="904-1403">
<Initialization range="0-903"/>
</SegmentBase>
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.640015" width="420" height="270" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="644824">
<BaseURL>700_dashinit.mp4</BaseURL>
<SegmentBase indexRangeExact="true" indexRange="905-1404">
<Initialization range="0-904"/>
</SegmentBase>
</Representation>
<Representation id="3" mimeType="video/mp4" codecs="avc1.64001f" width="1024" height="576" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="1349484">
<BaseURL>1500_dashinit.mp4</BaseURL>
<SegmentBase indexRangeExact="true" indexRange="905-1404">
<Initialization range="0-904"/>
</SegmentBase>
</Representation>
<Representation id="4" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="2264379">
<BaseURL>2500_dashinit.mp4</BaseURL>
<SegmentBase indexRangeExact="true" indexRange="905-1404">
<Initialization range="0-904"/>
</SegmentBase>
</Representation>
<Representation id="5" mimeType="video/mp4" codecs="avc1.640028" width="1920" height="1080" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="3633049">
<BaseURL>4000_dashinit.mp4</BaseURL>
<SegmentBase indexRangeExact="true" indexRange="906-1405">
<Initialization range="0-905"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>
我正在使用 video.js 和 dash.js 在客户端播放 mpeg dash 内容。问题是当我从 chrome 开发工具模拟网络条件时,视频无法完美播放。
它有时有效,但对其他人无效。例如,流以 400kbps 的比特率开始,然后检测到足够的可用带宽,因此它切换到 2500kbps。然后,当我再次将带宽降低到 400kbps 时,视频会在某个时间点冻结。
有时,当它尝试切换流时,视频在播放的最初几秒钟后会冻结。我认为在通过 ffmpeg 生成视频文件或通过 MP4Box 生成 .mpd 文件时可能缺少一些命令行参数。
以下是我用于 ffmpeg 和 MP4Box 的命令
ffmpeg -y -i inputfile -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -r 24 – g 24 -b:v 1500k -maxrate 1500k -bufsize 1000k -vf "scale=-1:720" outputfile.mp4
MP4Box -dash [DURATION] -rap -frag-rap -profile [PROFILE] -out [path/to/outpout.file] [path/to/input1.file] [path/to/input2.file] [path/to/input3.file]
此外,当我通过 MP4Box 生成 .mpd 文件时,我在控制台中收到以下警告
[DASH]: Files have non-proportional track layouts (320x240 vs 420x270) but sample size and aspect ratio match, assuming precision issue
[DASH]: Files have non-proportional track layouts (320x240 vs 1024x576) but sample size and aspect ratio match, assuming precision issue
[DASH]: Files have non-proportional track layouts (320x240 vs 1280x720) but sample size and aspect ratio match, assuming precision issue
[DASH]: Files have non-proportional track layouts (320x240 vs 1920x1080) but sample size and aspect ratio match, assuming precision issue
每当视频停止播放时,chrome 控制台都会有这些日志
Number of times the buffer has run dry: 25
Apply STRONG to buffer rule.
Quit switching bit rates.
我不知道为什么缓冲区会干涸并且它会停止切换比特率。
在这个过程中有什么主要是错误的吗?