首页 > 解决方案 > 从 *.ts 文件生成 m3u8 播放列表

问题描述

我使用 FFmpeg 生成了 hls 视频。但是我忘记放了-hls_list_size 0。现在它只包含最后 4 个文件。有没有办法使用文件夹内的所有 *.ts 文件只生成 .m3u8 播放列表文件?

标签: ffmpeghttp-live-streamingm3u8

解决方案


Assuming you do not have the source or you do not want to re-construct the whole playlist, write a bash script to pick the duration of each segment using the command

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ts_files/sample_000.ts

Once you have the segment lengths, it should be quite simple IMHO.

Of-course, you'd want the bash to iterate through the *.ts files in a sorted order (by name/created at).

While the above may do the job, go through this and this once.


推荐阅读