Awais fiaz
Awais fiaz

Reputation: 380

Reducing HLS latency time FFmpeg

Hi there i am working on dynamic HLS streaming i have created the playlists of 4 different resolutions and wrapped them into one master playlist for dynamic streaming but when i put that into server and try to stream video the latency time comes very much higher even more than a minute for IOS devices also for desktop PC's and Android devices its more than 30 seconds

is there any way how can i reduce the latency time.

here is my command for encoding videos for HLS using FFmpeg

ffmpeg -i /var/www/html/file_conversion/io_legend.mp4 \
-profile:v baseline -level 3.0 -s 428x240 -aspect 1.77916 -c:v libx264 -b:v 440k -g 250 -framerate 30 -c:a libfdk_aac -b:a 320k -hls_list_size 0 -start_number 0 -hls_init_time 2 -hls_time 8  -f hls /var/www/html/file_conversion/legend_hls/legend_240.m3u8 \
-profile:v baseline -level 3.1 -s 640x360 -aspect 1.77916 -c:v libx264 -b:v 600k -g 250 -framerate 30 -c:a libfdk_aac -b:a 320k -hls_list_size 0 -start_number 0 -hls_init_time 2 -hls_time 8  -f hls /var/www/html/file_conversion/legend_hls/legend_360.m3u8 \
-profile:v baseline -level 3.1 -s 854x480 -aspect 1.77916 -c:v libx264 -b:v 700k -g 250 -framerate 30 -c:a libfdk_aac -b:a 320k -hls_list_size 0 -start_number 0 -hls_init_time 2 -hls_time 8  -f hls /var/www/html/file_conversion/legend_hls/legend_480.m3u8 \
-profile:v baseline -level 4.0 -s 1280x720 -aspect 1.77916 -c:v libx264 -b:v 880k -g 250 -framerate 30 -c:a libfdk_aac -b:a 320k -hls_list_size 0 -start_number 0 -hls_init_time 2 -hls_time 8  -f hls /var/www/html/file_conversion/legend_hls/legend_720.m3u8

here is my master playlist for dynamic adaptive streaming

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,RESOLUTION=428x240
legend_240.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2855600,RESOLUTION=640x360
legend_360.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5605600,RESOLUTION=854x480
legend_480.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7305600,RESOLUTION=1280x720
legend_720.m3u8

any help regarding this issue would be really appreciated Thanks have a good day!

Upvotes: 2

Views: 3421

Answers (1)

Brad
Brad

Reputation: 163232

Your GOP length is 250 and your frame rate is 30, meaning you have over 8 seconds per chunk. While that's fantastic as far as quality and efficiency goes, it causes an increase in latency. Most clients are going to need a couple segments before they start playback. Reduce those and your latency will go down.

Beware though, you'll be making everything less efficient.

If you actually care about latency, you shouldn't be using a segmented protocol like HLS to begin with.

Upvotes: 3

Related Questions