linux - 重新排列m3u8中ts文件的顺序会导致播放时卡住

标签 linux ffmpeg encode http-live-streaming

我有一个 m3u8 文件和几个 TS 文件。
以下是 m3u8 文件的实际输出。

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:5
#EXTINF:4.027222,
test0000.ts
#EXTINF:4.004000,
test0001.ts
#EXTINF:4.004000,
test0002.ts
#EXTINF:4.004000,
test0003.ts
#EXT-X-ENDLIST
我把这个m3u8改写成如下格式,保存,播放。
然后视频的播放顺序和我换m3u8的顺序一模一样。
但是,视频播放无法按预期工作并卡住。
#extm3u.
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:5
#EXTINF:4.027222,
test0003.ts
#EXTINF:4.004000,
test0002.ts
#EXTINF:4.004000,
test0001.ts
#EXTINF:4.004000,
test0000.ts 
#EXT-X-ENDLIST
如果我想像这样更改 TS 文件的顺序,如何编辑 m3u8 文件?
或者我可以使用 ffmpeg 命令更改 ts 文件的顺序,然后重新创建 m3u8 文件吗?

最佳答案

恐怕您不允许手动编辑播放列表(或使用 ffmpeg 命令重新生成它)。由于the restriction of HLS protocol (RFC8216) ,当您设置任一值 .ts 时,不得删除中间的媒体片段(在您的情况下为 event 文件)或 vod-hls_playlist_type您的 ffmpeg 中的选项命令,即使没有 -hls_playlist_type ,它仍然仅限于更改播放列表(不包括自由删除任何媒体片段)。
引自 General Server Responsibilities in RFC8216

The server MUST NOT change the Media Playlist file, except to:

  • Append lines to it (Section 6.2.1).
  • Remove Media Segment URIs from the Playlist in the order that they appear, along with any tags that apply only to those segments (Section 6.2.2).
  • Increment the value of the EXT-X-MEDIA-SEQUENCE or EXT-X- DISCONTINUITY-SEQUENCE tags (Section 6.2.2).
  • Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

A Media Playlist has further constraints on its updates if it contains an EXT-X-PLAYLIST-TYPE tag. An EXT-X-PLAYLIST-TYPE tag with a value of VOD indicates that the Playlist file MUST NOT change. An EXT-X-PLAYLIST-TYPE tag with a value of EVENT indicates that the server MUST NOT change or delete any part of the Playlist file; it MAY append lines to it.


请注意 EXT-X-PLAYLIST-TYPE在与 -hls_playlist_type 相关的播放列表中在 ffmpeg

关于linux - 重新排列m3u8中ts文件的顺序会导致播放时卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70870529/

相关文章:

ios - Swift:如何以枚举为键对 HashMap 进行编码?

linux - 低功耗蓝牙 : listening for notifications/indications in linux

linux - 多个线程定期更新全局变量,而第三个线程等待读取

ffmpeg - 将带隐藏字幕的 TS 转换为带字幕的 MKV/MP4

ffmpeg - 在转码为 mpegts 时,ffmpeg 在 1.48 秒延迟后创建第一帧

php - json如何编码格式?

c++ - 在可移植应用程序中使用 Windows DLL

linux - 在 shell 脚本中结合 ssh 和 scp 命令

ffmpeg。输入过程结束时出现段错误

java - 2 字节 UTF-8 序列的字节 2 无效 : XML saved as String varible