·设为首页收藏本站📧邮箱修改🎁免费下载专区🔐设置/修改密码👽群雄群聊
返回列表 发布新帖

用ffmpeg 把mp4文件转为ts文件并生成m3u8列表

368 0
发表于 2020-7-7 10:02:33 | 显示全部楼层 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
在使用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文件啦
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图

您的IP:18.224.32.86,111.170.22.67,GMT+8, 2024-5-7 04:03 , Processed in 0.145727 second(s), 68 queries , Gzip On, Redis On.

Based on Discuz! W1.0 Licensed

© 2001-2024 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表