为什么M3U8文件在我手动更改M3U8文件时播放不好
我使用 ffmpeg
将mp4更改为.ts
ffmpeg -y -i [fileName].mp4 -vcodec copy -vbsf h264_mp4toannexb [outPutFileName].ts
并获取以下 index.m3U8
文件
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:22
#EXTINF:21.804344,
out-0000.ts
#EXTINF:10.847822,
out-0001.ts
#EXTINF:12.239122,
out-0002.ts
#EXT-X-ENDLIST
,然后我使用 hls.js
播放此文件
,很好,
但是现在我想将此 index.m3u8
文件更改为此(复制This of this of of not02.ts,重复opt of 02.ts)
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:22
#EXTINF:21.804344,
out-0000.ts
#EXTINF:10.847822,
out-0001.ts
#EXTINF:12.239122,
out-0002.ts
#EXTINF:12.239122,
out-0002.ts
#EXTINF:12.239122,
out-0002.ts
#EXT-X-ENDLIST
结果是此视频播放时间
更改正如预期的那样
,但是out02不会重复,当它播放到第一个out2.t的末尾时,屏幕粘在of00的开始时,
为什么当我自己编辑此文件时它不正常?
或者我使用 ffmpeg
更新此 index.m3U8
文件?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里提出了一个类似的问题并回答:在这里: 从那里多次进入M3U8播放列表?
从那里,您只需要在M3U8文件中标记每个不连续性所需的信息即可。您可以通过添加#Ext-X-Discontinuition标志来做到这一点。
例如,您的M3U8文件应该看起来如下:
这是因为这是因为OUT-0002.TS文件的结束,因此播放out-0002.TS重置视频演示时间戳,导致不连续性,导致不连续性时间戳值在同一文件开头的时间戳之后的12.239122秒。
此处的更多信息: https://datatracker.ietf.org.org/doc/doc/doc/html/html/rfc8216
A similar question was asked and answered here: hls manually add second .ts file to playlist and here: How to include same segment into m3u8 playlist multiple times?
From there, you just need the piece of information that you need to mark each and every discontinuity in the m3u8 file. You do it by adding the #EXT-X-DISCONTINUITY flag.
For example, your m3u8 file should look like the following:
This is because playing over and again the out-0002.ts resets the video presentation timestamps over and again, causing a discontinuity, as the ending of the out-0002.ts file has timestamp values 12.239122 seconds after the timestamps of the beginning of the same file.
Further information here: https://datatracker.ietf.org/doc/html/rfc8216