简体   繁体   English

FFMpeg HLS 视频转码生成部分播放列表

[英]FFMpeg HLS Video Transcoding Generating Partial Playlist

I'm trying to convert a basic mp4 video into an HLS video using ffmpeg (running on OSX) using the following command:我正在尝试使用 ffmpeg(在 OSX 上运行)使用以下命令将基本 mp4 视频转换为 HLS 视频:

ffmpeg -i SampleVideo_1280x720_10mb.mp4 -codec:v libx264 -codec:a aac -strict experimental -start_number 1 out.m3u8

It does manage to generate all of the .ts segment files, but the resulting .m3u8 playlist file only lists the final four segment files, cutting out any earlier segments.它确实设法生成了所有.ts片段文件,但生成的.m3u8播放列表文件仅列出了最后四个片段文件,并删除了任何较早的片段。 Help?帮助?

According to the ffmpeg documentation , the playlist defaults to 5 entries and a segment duration of 2 seconds.根据ffmpeg 文档,播放列表默认为 5 个条目,片段持续时间为 2 秒。 This probably explains why you are only seeing a limited number of entries in the playlist.这可能解释了为什么您只能在播放列表中看到有限数量的条目。 Try setting the length of the playlist ( -hls_list_size ) to 0, which will include all the segments.尝试将播放列表的长度 ( -hls_list_size ) 设置为 0,这将包括所有片段。 Apple recommends a segment duration of 10 seconds. Apple 建议分段持续时间为 10 秒。 You can set the segment duration with the -hls_time option.您可以使用-hls_time选项设置段持续时间。

For reference, you can also use the segment muxer.作为参考,您还可以使用复用器。 Here's the command I usually use when segmenting video with ffmpeg :这是我在使用 ffmpeg 分割视频时通常使用的命令:

ffmpeg -y \
 -i input.mov \
 -codec copy \
 -bsf h264_mp4toannexb \
 -map 0 \
 -f segment \
 -segment_time 10 \
 -segment_format mpegts \
 -segment_list "/Library/WebServer/Documents/vod/prog_index.m3u8" \
 -segment_list_type m3u8 \
 "/Library/WebServer/Documents/vod/fileSequence%d.ts"

In this instance, the input video contains H.264 video and AAC audio so it doesn't need to be transcoded.在这种情况下,输入视频包含 H.264 视频和 AAC 音频,因此不需要进行转码。

尝试

ffmpeg -i SampleVideo_1280x720_10mb.mp4 -c:v libx264 -c:a aac -strict -2 -start_number 1 -hls_list_size 0 out.m3u8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM