用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
来源:互联网 发布:淘宝推广工具 编辑:程序博客网 时间:2024/05/29 18:02
在使用hls技术播放视频流时,首先要把视频转换为ts片和一个m3u8播放列表,使用ffmpeg进行该转换时(低版本ffmpeg不支持直接转,只能现在转换成ts,再用m3u8-segmenter切片,笔者使用的是ffmpeg version-2.1.2),通常使用如下命令:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -strict -2 -f hls output.m3u8
但是在此状态下,默认的每片长度为2秒,m3u8文件中默认只保存最新的5条片的信息,导致最后播放的时候只能播最后的一小部分。
实际上还有一些其他参数可以控制这些内容:
以下为ffmpeg官网原文:
This muxer supports the following options:
- ‘hls_time seconds’
Set the segment length in seconds. Default value is 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.
- ‘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.
- ‘start_number number’
Start the playlist sequence number from number. Default value is 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.
翻译如下:
-hls_time n: 设置每片的长度,默认值为2。单位为秒
-hls_list_size n:设置播放列表保存的最多条目,设置为0会保存有所片信息,默认值为5
-hls_wrap n:设置多少片之后开始覆盖,如果设置为0则不会覆盖,默认值为0.这个选项能够避免在磁盘上存储过多的片,而且能够限制写入磁盘的最多的片的数量
-hls_start_number n:设置播放列表中sequence number的值为number,默认值为0
注意:播放列表的sequence number 对每个segment来说都必须是唯一的,而且它不能和片的文件名(当使用wrap选项时,文件名有可能会重复使用)混淆
加上了这些参数,小伙伴们就可以愉快地控制生成的m3u8文件啦
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- ffmpeg对mp4文件进行ts切片并生成m3u8文件
- ffmpeg 视频转ts切片并生成m3u8播放列表文件
- ffmpeg 教程之 mp4 文件转换为m3u8 ts 文件
- ffmpeg文件生成m3u8文件及ts切片程序(一)
- ffmpeg文件生成m3u8文件及ts切片程序(一)
- 关于使用ffmpeg把mp4转化m3u8文件的命令
- 利用ffmepg把ts文件转m3u8并切片
- 后缀名m3u8文件转为一个ts文件---利用word vba
- 使用FFmpeg将文件转为ts
- ffmpeg 读取 rtmp流 编码成ts m3u8文件
- 运用ffmpeg生成MP4文件
- 运用ffmpeg生成MP4文件
- Tensorflow手写体识别mnist
- 系统架构Prototype
- 之前一直做功能测试,现在想往自动化测试发展
- PageRank算法--从原理到实现
- Android Studio 使用技巧
- 用ffmpeg 把mp4文件转为ts文件并生成m3u8列表
- BZOJ 3489: A simple rmq problem 树套树
- VS+Opencv3.3下用HOG+SVM实现INRIA行人检测
- python 关键字 保留字
- 斯坦福大学机器学习笔记——正则化的逻辑回归模型
- 第二次试验
- Android的Handler机制
- Java将字符串按指定长度分割
- Linux上配置Jupyter Notebook远程访问