当前位置: 首页 > 知识库问答 >
问题:

ffmpeg-mp4box-mpeg dash只播放少数片段

东深
2023-03-14

需要调试段划线文件的帮助吗

输入是带有这些细节的MP4。这是从摄像机录制的,摄像机的输出是mkv,我们通过adobe编辑音频后转换为MP4

  • 大小:7.51 GB帧率:25帧/秒
  • 数据速率:25326kbps
  • 总比特率:25525kbps

使用此命令将其转换为另一个mp4

ffmpeg -i "input.mp4" -s 1280x720 -c:v libx264 -b:v 750k -bf 2 -g 75 -sc_threshold 0 -an video_1280x720_750k.mp4

ffmpeg -i "input.mp4"  -c:a aac -strict experimental -b:a 96k -ar 32000 -vn audio_96k.mp4

输出视频已被删除

  • fps:25
  • 数据速率:761kbps
  • 比特率:761kbps

然后,通过MP4Box创建了分段破折号

MP4Box -dash 10000 -frag 10000 -rap -segment-name video_0_1280000\segment_ video_1280x720_750k.mp4

MP4Box -dash 3000 -frag 10000 -rap -segment-name audio_0_96000\segment_ audio_96k.mp4

生成的MPD经过在线验证,其性能完美

更新!包括MPD文件

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.5.2-DEV-rev621-g236c5f8-master  at 2015-10-26T05:16:19.619Z-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H2M0.000S" maxSegmentDuration="PT0H0M10.000S" profiles="urn:mpeg:dash:profile:full:2011">
 <ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
  <Title>video_1280x720_500k_dash.mpd generated by GPAC</Title>
 </ProgramInformation>

 <Period duration="PT0H2M0.000S">
   <AdaptationSet segmentAlignment="true" lang="eng">
     <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="32000" startWithSAP="1" bandwidth="98434">
       <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
       <SegmentList timescale="32000" duration="319999">
         <Initialization sourceURL="audio_0_96000/segment_init.mp4"/>
         <SegmentURL media="audio_0_96000/segment_1.m4s"/>
         <SegmentURL media="audio_0_96000/segment_2.m4s"/>
         <SegmentURL media="audio_0_96000/segment_3.m4s"/>
         <SegmentURL media="audio_0_96000/segment_4.m4s"/>
         <SegmentURL media="audio_0_96000/segment_5.m4s"/>
         <SegmentURL media="audio_0_96000/segment_6.m4s"/>
         <SegmentURL media="audio_0_96000/segment_7.m4s"/>
         <SegmentURL media="audio_0_96000/segment_8.m4s"/>
         <SegmentURL media="audio_0_96000/segment_9.m4s"/>
         <SegmentURL media="audio_0_96000/segment_10.m4s"/>
         <SegmentURL media="audio_0_96000/segment_11.m4s"/>
         <SegmentURL media="audio_0_96000/segment_12.m4s"/>
         <SegmentURL media="audio_0_96000/segment_13.m4s"/>
       </SegmentList>
     </Representation>
   </AdaptationSet>
  <AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720" maxFrameRate="25" par="16:9" lang="eng">
   <Representation id="1" mimeType="video/mp4" codecs="avc3.64001f" width="1280" height="720" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="764668">
    <SegmentList timescale="12800" duration="125866">
     <Initialization sourceURL="video_0_1280000/segment_init.mp4"/>
     <SegmentURL media="video_0_1280000/segment_1.m4s"/>
     <SegmentURL media="video_0_1280000/segment_2.m4s"/>
     <SegmentURL media="video_0_1280000/segment_3.m4s"/>
     <SegmentURL media="video_0_1280000/segment_4.m4s"/>
     <SegmentURL media="video_0_1280000/segment_5.m4s"/>
     <SegmentURL media="video_0_1280000/segment_6.m4s"/>
     <SegmentURL media="video_0_1280000/segment_7.m4s"/>
     <SegmentURL media="video_0_1280000/segment_8.m4s"/>
     <SegmentURL media="video_0_1280000/segment_9.m4s"/>
     <SegmentURL media="video_0_1280000/segment_10.m4s"/>
     <SegmentURL media="video_0_1280000/segment_11.m4s"/>
     <SegmentURL media="video_0_1280000/segment_12.m4s"/>
     <SegmentURL media="video_0_1280000/segment_13.m4s"/>
    </SegmentList>
   </Representation>
  </AdaptationSet>

 </Period>
</MPD>

通过dashjs播放视频。。我相信它只是播放最初的片段,并在媒体解码时出错。。不支持媒体错误。。或者是说找不到开始的消息。。

通过chrome调试,我看到至少有4个段正在正确加载...我不确定发生了什么...

非常感谢对调试问题的任何帮助。我真的不明白这是文件、ffmpeg、mp4box还是chrome的问题。

chrome调试工具的输出

[dash.js 1.5.1] new MediaPlayer instance has been created 
dash.all.js:11 Playback initiated! 
dash.all.js:11 Parsing complete: ( xml2json: 5ms, objectiron: 10ms, total: 0.015s) 
dash.all.js:11 Manifest has been refreshed at Mon Oct 26 2015 10:19:22 GMT-0400 (Eastern Daylight Time)[1445869162092]  
dash.all.js:11 SegmentTimeline detected using calculated Live Edge Time 
dash.all.js:11 MediaSource is open! 
dash.all.js:11 [object Event] 
dash.all.js:11 Duration successfully set to: 120 
dash.all.js:11 Added 0 inline events 
dash.all.js:11 video codec: video/mp4;codecs="avc3.64001f" 
dash.all.js:11 [video] stop 
dash.all.js:11 audio codec: audio/mp4;codecs="mp4a.40.2" 
dash.all.js:11 [audio] stop 
dash.all.js:11 No text data. 
dash.all.js:11 No fragmentedText data. 
dash.all.js:11 No muxed data. 
dash.all.js:11 [video] start 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 [video] SegmentList: 0 / 120 
dash.all.js:11 [audio] start 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 [audio] SegmentList: 0 / 120 
dash.all.js:11 [video] Getting the request for time: 9.83328125 
dash.all.js:11 [video] Index for time 9.83328125 is 0 
dash.all.js:11 [video] SegmentList: 0 / 120 
dash.all.js:11 [video] SegmentList: 9.83328125 / 120 
dash.all.js:11 [audio] Getting the request for time: 9.99996875 
dash.all.js:11 [audio] Index for time 9.99996875 is 0 
dash.all.js:11 [audio] SegmentList: 0 / 120 
dash.all.js:11 [audio] SegmentList: 9.99996875 / 120 
dash.all.js:11 loaded audio:Media Segment:0 (200, 20ms, 6ms) 
dash.all.js:11 loaded video:Media Segment:0 (200, 153ms, 43ms) 
dash.all.js:11 loaded video:Initialization Segment:NaN (200, 0ms, 32ms) 
dash.all.js:11 [video] Initialization finished loading 
dash.all.js:11 loaded audio:Initialization Segment:NaN (200, 0ms, 34ms) 
dash.all.js:11 [audio] Initialization finished loading 
dash.all.js:11 [video] Getting the request for time: 19.6665625 
dash.all.js:11 [video] Index for time 19.6665625 is 1 
dash.all.js:11 [video] SegmentList: 9.83328125 / 120 
dash.all.js:11 [video] SegmentList: 19.6665625 / 120 
dash.all.js:11 [audio] Getting the request for time: 19.9999375 
dash.all.js:11 [audio] Index for time 19.9999375 is 1 
dash.all.js:11 [audio] SegmentList: 9.99996875 / 120 
dash.all.js:11 [audio] SegmentList: 19.9999375 / 120 
dash.all.js:11 [video] Stalling Buffer 
dash.all.js:11 [video] Waiting for more buffer before starting playback. 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 [audio] Stalling Buffer 
dash.all.js:11 [audio] Waiting for more buffer before starting playback. 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 <video> loadedmetadata 
dash.all.js:11 Starting playback at offset: 0 
dash.all.js:11 [video] Getting the request for time: 29.499843750000004 
dash.all.js:11 [video] Index for time 29.499843750000004 is 2 
dash.all.js:11 [video] SegmentList: 19.6665625 / 120 
dash.all.js:11 [video] SegmentList: 29.499843750000004 / 120 
dash.all.js:11 [video] Got enough buffer to start. 
dash.all.js:11 [video] seek: 0 
dash.all.js:11 [audio] Getting the request for time: 29.999906250000002 
dash.all.js:11 [audio] Index for time 29.999906250000002 is 2 
dash.all.js:11 [audio] SegmentList: 19.9999375 / 120 
dash.all.js:11 [audio] SegmentList: 29.999906250000002 / 120 
dash.all.js:11 [audio] Got enough buffer to start. 
dash.all.js:11 [audio] seek: 0 
dash.all.js:11 loaded audio:Media Segment:9.99996875 (200, 67ms, 24ms) 
dash.all.js:11 loaded video:Media Segment:9.83328125 (200, 71ms, 31ms) 
dash.all.js:11 [audio] Buffered Range: 0.032 - 9.984 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 Start Event Controller 
dash.all.js:11 [audio] Buffered Range: 0.032 - 19.999968 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 <video> play 
dash.all.js:11 [video] start 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 [video] SegmentList: 0 / 120 
dash.all.js:11 [video] SegmentList: 9.83328125 / 120 
dash.all.js:11 [video] SegmentList: 19.6665625 / 120 
dash.all.js:11 [audio] start 
dash.all.js:11 <video> playing 
dash.all.js:11 [video] Buffered Range: 0 - 9 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 Do seek: 0.032 
dash.all.js:11 <video> seek 
dash.all.js:11 [video] Getting the request for time: 29.499843750000004 
dash.all.js:11 [video] Index for time 29.499843750000004 is 2 
dash.all.js:11 [video] SegmentList: 19.6665625 / 120 
dash.all.js:11 [video] SegmentList: 29.499843750000004 / 120 
dash.all.js:11 [video] seek: 0.032 
dash.all.js:11 [audio] seek: 0.032 
dash.all.js:11 [video] Getting the request for time: 9 
dash.all.js:11 [video] Index for time 9 is 0 
dash.all.js:11 [video] SegmentList: 0 / 120 
dash.all.js:11 [video] SegmentList: 9.83328125 / 120 
dash.all.js:11 [video] SegmentList: 19.6665625 / 120 
dash.all.js:11 [video] SegmentList: 29.499843750000004 / 120 
dash.all.js:11 [video] Buffered Range: 0 - 18 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 loaded video:Media Segment:19.6665625 (200, 42ms, 33ms) 
dash.all.js:11 <video> seeked 
dash.all.js:11 Start Event Controller 
dash.all.js:11 <video> playing 
dash.all.js:11 [video] Buffered Range: 0 - 28 
dash.all.js:11 [video] Getting the request for time: 0 
dash.all.js:11 [video] Index for time 0 is 0 
dash.all.js:11 [audio] Getting the request for time: 19.999968 
dash.all.js:11 [audio] Index for time 19.999968 is 1 
dash.all.js:11 [audio] SegmentList: 9.99996875 / 120 
dash.all.js:11 [audio] SegmentList: 19.9999375 / 120 
dash.all.js:11 [audio] Getting the request for time: 29.999906250000002 
dash.all.js:11 [audio] Index for time 29.999906250000002 is 2 
dash.all.js:11 [audio] SegmentList: 19.9999375 / 120 
dash.all.js:11 [audio] SegmentList: 29.999906250000002 / 120 
dash.all.js:11 loaded audio:Media Segment:19.9999375 (200, 102ms, 2ms) 
dash.all.js:11 [audio] Buffered Range: 0.032 - 29.983968 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 loaded audio:Media Segment:29.999906250000002 (200, 26ms, 2ms) 
dash.all.js:11 [audio] Buffered Range: 0.032 - 39.999968 
dash.all.js:11 [audio] Getting the request for time: 0 
dash.all.js:11 [audio] Index for time 0 is 0 
dash.all.js:11 loaded video:Media Segment:29.499843750000004 (200, 47ms, 7ms) 
dash.all.js:11 Video Element Error: MEDIA_ERR_DECODE 
dash.all.js:11 [video] stop 
dash.all.js:11 [audio] stop 
dash.all.js:11 Video Element Error: MEDIA_ERR_SRC_NOT_SUPPORTED 
dash.all.js:11 <video> play 

共有2个答案

竺鸿骞
2023-03-14

这很可能是浏览器播放问题,因为浏览器支持哪些编解码器。

尝试在此处添加编解码器字符串,查看它们是否播放:http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_av_met_canplaytype

而avc3。64001f应该在某些浏览器中播放它,您可以尝试主配置文件,尝试在输入文件后将其添加到ffmpeg命令中

-profile:v main
拓拔弘化
2023-03-14

你已经分别尝试过音频和视频了吗?这至少可以隔离错误。

您还可以尝试根据http://www.dash-player.com/blog/2014/11/mpeg-dash-content-generation-using-mp4box-and-x264/,这对我很有用。

 类似资料:
  • 我为我的游戏编写了一个定制的声音系统,但如果要求在几毫秒内播放两个声音,则只能播放一个声音片段。 我尝试在这样的新线程上运行播放,但它不起作用。没有例外,它只是不会播放两种声音。 这是声音播放器类

  • 将(从webm、rtmp等任何格式)编码为通用hls或dash格式的“好”方法是什么??? 我看到大量关于HLS和MPEG-DASH的讨论,视频标签看起来像这样 但FFMPEG中的好命令是什么? 当我这么做的时候 它只能在chrome中播放:( 但我需要它能在safari、firefox、opera等平台上播放 我最近看过关于MP4box的讨论,能将任何源代码转换成通用可播放流的最佳线路是什么?

  • 我已经转码并剥离了mp4文件的音频,如下所示: $ffmpeg-编解码器:a libvo_aacenc-ar 44100-ac 1-编解码器:v libx264-配置文件:v基线-级别13-b:v 2000k直接/输出。mp4-我是导演/原著。mp4 $ffmpeg-i dir/out。mp4-一个目录/输出。mp4 我使用了以下MP4Box命令来生成mpd: $MP4Box-dash 30000

  • 通过最近的ffmpeg主分支(commit7fcbeb),我们可以使用以下方法生成主播放列表 -master_pl_name 选项。但我无法生成具有不同配置文件的主播放列表。尝试使用 -var_stream_map 我们如何使用这些选项来创建具有不同配置文件的主播放列表? 我正在尝试使用下面的ffmpeg命令:

  • 我是一名大学生,现在正在学习FFmpeg。 当我使用这个公式时,我发现一个现象。 1.帧率越高,视频播放速度越快。 2.帧率越慢,视频播放速度越快。 我希望无论帧率是多少,视频播放速度都是合适的。不要太快或太慢。

  • 播放幻灯片秀 自动依顺序显示每张图像。 选择频道或图像时按下按钮,再选择选项选单的[幻灯片秀]。 提示 显示图像时若按下START(开始)按钮,即会开始幻灯片秀。 幻灯片秀可与音乐同时播放。详细内容请参阅(相片) > [幻灯片秀] > [同时播放音乐与幻灯片秀]。