1

我已使用 ffmpeg 为破折号播放器编码我的视频 sample.mp4 的音频和视频文件。命令如下:

ffmpeg -i sample.mp4 -s 426x240 -c:v libx264 -b:v 640k -g 90 -an sample_video_240.mp4
ffmpeg -i sample.mp4 -s 480x360 -c:v libx264 -b:v 960k -g 90 -an sample_video_360.mp4
ffmpeg -i sample.mp4 -s 640x480 -c:v libx264 -b:v 1280k -g 90 -an sample_video_480.mp4
ffmpeg -i sample.mp4 -s 1280x720 -c:v libx264 -b:v 2560k -g 90 -an sample_video_720.mp4

ffmpeg -i sample.mp4 -c:a aac -b:a 128k -vn sample_audio.mp4

我生成了 240p、360p、480p 和 720p 视频和音频文件。

然后我使用 mp4box 使用以下命令生成 mpd 文件:

mp4box -dash 10000 -rap -profile dashavc264:onDemand -mpd-title BBB -out sample.mpd -frag 5000 sample_audio.mp4 sample_video_240.mp4 sample_video_360.mp4 sample_video_480.mp4 sample_video_720.mp4 

我正在使用 dash.js 播放器播放视频。问题是,DASH 的自适应部分不起作用。播放器仅使用 240p 视频,即使有适当的带宽,也不会切换到更好的格式。我正在使用 chrome 开发工具的网络选项卡进行检查。

我究竟做错了什么?请帮忙。

这是mpd文件供参考:

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.7.0-rev0-gbd5c9af-master  at 2019-01-24T17:58:56.373Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H1M9.869S" maxSegmentDuration="PT0H0M9.985S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011,http://dashif.org/guidelines/dash264">
 <ProgramInformation moreInformationURL="http://gpac.io">
  <Title>BBB</Title>
 </ProgramInformation>

 <Period duration="PT0H1M9.869S">
  <AdaptationSet segmentAlignment="true" lang="und" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
   <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="130920">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
    <BaseURL>sample_audio_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="902-1017">
      <Initialization range="0-901"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" group="1" maxWidth="426" maxHeight="240" maxFrameRate="30" par="426:240" lang="und" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
   <Representation id="2" mimeType="video/mp4" codecs="avc1.640015" width="426" height="240" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="590708">
    <BaseURL>sample_video_240_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="914-1053">
      <Initialization range="0-913"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" group="1" maxWidth="640" maxHeight="480" maxFrameRate="30" par="4:3" lang="und" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
   <Representation id="3" mimeType="video/mp4" codecs="avc1.64001E" width="480" height="360" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="883873">
    <BaseURL>sample_video_360_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="914-1053">
      <Initialization range="0-913"/>
    </SegmentBase>
   </Representation>
   <Representation id="4" mimeType="video/mp4" codecs="avc1.64001E" width="640" height="480" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="1188712">
    <BaseURL>sample_video_480_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="913-1052">
      <Initialization range="0-912"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" group="1" maxWidth="1280" maxHeight="720" maxFrameRate="30" par="16:9" lang="und" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
   <Representation id="5" mimeType="video/mp4" codecs="avc1.64001F" width="1280" height="720" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="2365717">
    <BaseURL>sample_video_720_dashinit.mp4</BaseURL>
    <SegmentBase indexRangeExact="true" indexRange="914-1053">
      <Initialization range="0-913"/>
    </SegmentBase>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>
4

0 回答 0