Ffmpeg hls直播 - 如何生成较短的片段 [英] Ffmpeg hls live streaming - How to generate shorter segments

查看:919
本文介绍了Ffmpeg hls直播 - 如何生成较短的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ffmpeg通过HLS进行直播,并通过video.js播放。它工作,但在流开始到实际开始播放的时间之间有20秒的延迟。

Been using ffmpeg for live streaming via HLS and playing through video.js. It works but there is a 20s delay between the time the stream starts to the time it actually starts playing.

你知道为什么ffmpeg命令不能创建3秒的段,就像我在命令中定义的那样。细分趋向于9秒或10秒。不能让他们更短的尺寸

Do you know why ffmpeg command below doesn't create segements that are 3 seconds like I have defined it in the command. The segments tend to be 9s or 10s. Can't get them to a shorter size

ffmpeg -f x11grab -s 1280x720 -r 30 -i :0.0+nomouse -f alsa -ac 2 -i pulse -async 30 -vcodec libx264 -pix_fmt yuv420p -acodec libfdk_aac -ar 44100 -b:a 64k -threads 0 -s 640x360 -f hls -hls_time 1 -hls_list_size 1 -hls_allow_cache 0 /tmp/hls/#{@stream_name}/index.m3u8

这是m3u8播放列表文件:

Here is the m3u8 playlist file:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:9
#EXT-X-MEDIA-SEQUENCE:10
#EXTINF:8.333333,
index10.ts
#EXTINF:8.333333,
index11.ts
#EXTINF:8.333333,
index12.ts
#EXTINF:8.333333,
index13.ts
#EXTINF:2.366667,
index14.ts
#EXT-X-ENDLIST


推荐答案

您还必须指定关键帧间隔。也称为GOP(图片组)大小。

You must also specify the keyframe interval. Also known as the GOP (group of pictures) size.

-g [time]

这篇关于Ffmpeg hls直播 - 如何生成较短的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆