以下是重现步骤:
标准化 H.264 视频流
ffmpeg -i 2.h264 -c:v libx264 -intra -r 25 -vf scale=640x360,setdar=16:9 2@25fps@[email protected]
(*) 之后,我得到了一个 H.264 流,其中所有图片都是 H.264 IDR 帧,fps 为 25,分辨率为 640x360,纵横比为 16:9。
生成 MP4 文件
MP4Box -add 2@25fps@[email protected]:timescale=1000 -fps 25 2@25fps@[email protected]
制作破折号 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@[email protected]
我想从第一段的 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>
从 VLC 播放器或 Edge 浏览器播放 MPD url,它总是从第一段的第一帧开始,0s ~ 4s 之间的帧也意外显示。
我的步骤有什么问题?或者有其他选择吗?
已经澄清了!它在 Shakaplayer 中运行良好,但在 Edge 浏览器和 VLC 播放器中不起作用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句