首页 > 解决方案 > 如何制作在第一段中间开始播放的 MPEG-DASH MPD?

问题描述

以下是重现步骤:

  1. 标准化 H.264 视频流

    ffmpeg -i 2.h264 -c:v libx264 -intra -r 25 -vf scale=640x360,setdar=16:9 2@25fps@intra@640x360.h264

    (*) 之后,我得到一个 H.264 流,其中所有图片都是 H.264 IDR 帧,fps 为 25,分辨率为 640x360,纵横比为 16:9。

  2. 生成 MP4 文件

    MP4Box -add 2@25fps@intra@640x360.h264:timescale=1000 -fps 25 2@25fps@intra@640x360.mp4

  3. 制作 dash MP4 碎片化内容,包括 init mp4、.m4s 文件和一个 .mpd 文件

    MP4Box -dash 5000 -frag 5000 -dash-scale 1000 -frag-rap -segment-name 'seg_second$Number$' -segment-timeline -profile live 2@25fps@intra@640x360.mp4

  4. 将所有这些文件复制并发布到一台 HTTPD 服务器下的文件夹中
  5. 我想从第一段的 4s 开始播放,并且在 4s 之前不显示任何帧,所以我更改了 .MPD 文件以修改字段“SegmentTemplate@presentationTimeOffset”、“SegmentTimeline:S@d/t”,如:
    <?xml version="1.0"?> <MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500S" type="static" mediaPresentationDuration="PT0H0M26.000S" maxSegmentDuration="PT0H0M5.000S" profiles="urn:mpeg:dash:profile:isoff-live:2011"> <Period duration="PT0H0M26.000S"> <AdaptationSet segmentAlignment="true" maxWidth="640" maxHeight="360" maxFrameRate="25" par="16:9" lang="und"> <SegmentTemplate presentationTimeOffset="4000" media="seg_second$Number$.m4s" timescale="1000" startNumber="1" initialization="seg_secondinit.mp4"> <SegmentTimeline> <S d="1000" t="4000"/> <S d="5000" r="4"/> </SegmentTimeline> </SegmentTemplate> <Representation id="1" mimeType="video/mp4" codecs="avc3.64101E" width="640" height="360" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="2261831"> </Representation> </AdaptationSet> </Period> </MPD>

  6. 从 VLC 播放器或 Edge 浏览器播放 MPD url,总是从第一段的第一帧开始,0s ~ 4s 之间的帧也意外显示。

我的步骤有什么问题?或者有其他选择吗?

标签: ffmpegmp4mpeg-dashmp4box

解决方案


已经澄清了!它在 Shakaplayer 中运行良好,但在 Edge 浏览器和 VLC 播放器中不起作用。


推荐阅读