FFmpeg将MP4视频切割成ts文件
2017-10-09 15:51
495 查看
切片生成m3u8列表命令:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -strict -2 -f hls output.m3u8
此转换命令默认的每片(即一个ts文件)时长是2s,m3u8列表文件中默认只保存最后的5条片信息,也就是播放器在拉流时只能播最后的那5条ts视频文件。
这肯定不是你想要的,那么幸运的是ffmpeg提供了更改这些相关设置的参数,如下:
相关设置参数:
‘hls_time seconds’
Set the segment length in seconds. Default value is 2.(设置每片的长度,默认值为2。单位为秒)
‘hls_list_size size’
Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.(设置播放列表保存的最多条目,设置为0会保存有所片信息,默认值为5)
‘hls_wrap wrap’
Set the number after which the segment filename number (the number specified in each segment file) wraps. If set to 0 the number will be never wrapped. Default value is 0.
This option is useful to avoid to fill the disk with many segment files, and limits the maximum number of segment files written to disk towrap.(设置多少片之后开始覆盖,如果设置为0则不会覆盖,默认值为0.这个选项能够避免在磁盘上存储过多的片,而且能够限制写入磁盘的最多的片的数量)
‘start_number number’
Start the playlist sequence number from number. Default value is 0.(设置播放列表中sequence
number的值为number,默认值为0)
Note that the playlist sequence number must be unique for each segment and it is not to be confused with the segment filename sequence number which can be cyclic, for example if the ‘wrap’ option is
specified.(提示:播放列表的sequence number 对每个segment来说都必须是唯一的,而且它不能和片的文件名混淆,因为在,如果指定了“wrap”选项文件名会出现重复使用。)
使用示例:
ffmpeg -i 1.mp4 -c:v libx264 -c:a copy -f hls -threads 8 -hls_time 5 -hls_list_size 12 index.m3u8
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -strict -2 -f hls output.m3u8
此转换命令默认的每片(即一个ts文件)时长是2s,m3u8列表文件中默认只保存最后的5条片信息,也就是播放器在拉流时只能播最后的那5条ts视频文件。
这肯定不是你想要的,那么幸运的是ffmpeg提供了更改这些相关设置的参数,如下:
相关设置参数:
‘hls_time seconds’
Set the segment length in seconds. Default value is 2.(设置每片的长度,默认值为2。单位为秒)
‘hls_list_size size’
Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.(设置播放列表保存的最多条目,设置为0会保存有所片信息,默认值为5)
‘hls_wrap wrap’
Set the number after which the segment filename number (the number specified in each segment file) wraps. If set to 0 the number will be never wrapped. Default value is 0.
This option is useful to avoid to fill the disk with many segment files, and limits the maximum number of segment files written to disk towrap.(设置多少片之后开始覆盖,如果设置为0则不会覆盖,默认值为0.这个选项能够避免在磁盘上存储过多的片,而且能够限制写入磁盘的最多的片的数量)
‘start_number number’
Start the playlist sequence number from number. Default value is 0.(设置播放列表中sequence
number的值为number,默认值为0)
Note that the playlist sequence number must be unique for each segment and it is not to be confused with the segment filename sequence number which can be cyclic, for example if the ‘wrap’ option is
specified.(提示:播放列表的sequence number 对每个segment来说都必须是唯一的,而且它不能和片的文件名混淆,因为在,如果指定了“wrap”选项文件名会出现重复使用。)
使用示例:
ffmpeg -i 1.mp4 -c:v libx264 -c:a copy -f hls -threads 8 -hls_time 5 -hls_list_size 12 index.m3u8
相关文章推荐
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- ffmpeg封装h264裸流为mp4文件,视频播放速度特别慢-解决
- ffmpeg将视频文件转成ts文件
- ffmpeg 教程之 mp4 文件转换为m3u8 ts 文件
- ffmpeg之多个MP4视频合并一个MP4视频文件(附遇见的bug)
- 实现用FFmpeg接收RTSP,把H264视频和AAC音频录制成MP4文件(附完整代码)
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- ffmpeg代码笔记2:如何判断MP4文件里面的流是音频还是视频流
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- ffmpeg录制屏幕,生成MP4视频文件开发过程
- Java通过cmd调用FFmpeg实现大视频文件的分段切割
- Android音视频-FFmpeg推流Mp4文件到电脑端查看
- 使用FFMPEG从MP4封装中提取视频流到H264文件
- 使用ffmpeg将mp4文件中的h264码流转为raw h264文件格式或ts文件格式
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 使用FFMPEG从MP4封装中提取视频流到.264文件
- Android 音视频深入 十五 FFmpeg 推流mp4文件(附源码下载)
- ffmpeg 视频转ts切片并生成m3u8播放列表文件