使用MP4box的MPD中的自适应部分

时间:2019-01-28 06:32:57

标签: video ffmpeg mpeg-dash mp4box

我已经使用ffmpeg来为破折号播放器编码我的video 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>

0 个答案:

没有答案