Ffmpeg hls live streaming - How to generate shorter segments

一笑奈何 提交于 2019-11-29 23:05:36

问题


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.

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

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

回答1:


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

-g [time]



来源:https://stackoverflow.com/questions/28906259/ffmpeg-hls-live-streaming-how-to-generate-shorter-segments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!