Nginx-rtmp-module: hls_fragment directive doesn't work as expected.

Created on 16 May 2017  ·  2Comments  ·  Source: arut/nginx-rtmp-module

Hi, I'm having some trouble with hls_fragment directive. Here I want to set time of each fragment to 10 seconds:

application hls {
            live on;
            hls on;
            hls_path /home/myPC/hls;
        hls_playlist_length 10m;
        hls_fragment 10s;
        hls_continuous on;
        hls_cleanup off;
        }

However, fragments's length are not correct, this is my index.m3u8 file, you can see different length of each fragment:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:18
#EXT-X-DISCONTINUITY
#EXTINF:12.960,
Sample-0.ts
#EXTINF:10.640,
Sample-1.ts
#EXTINF:18.440,
Sample-2.ts
#EXTINF:10.000,
Sample-3.ts
#EXTINF:12.920,
Sample-4.ts
#EXTINF:10.800,
Sample-5.ts
#EXTINF:13.400,
Sample-6.ts
#EXTINF:12.240,
Sample-7.ts
#EXTINF:11.720,
Sample-8.ts
#EXTINF:15.320,
Sample-9.ts
#EXTINF:13.200,
Sample-10.ts
#EXTINF:10.480,
Sample-11.ts
#EXTINF:11.800,
Sample-12.ts
#EXTINF:6.932,
Sample-13.ts

The ffmpeg command that I use :

ffmpeg -loglevel verbose -re -i /home/myPC/video.mp4 -vcodec libx264 -vprofile baseline -acodec aac -strict -2 -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/SampleVideo

What I am doing wrong? Your help is very much appreciated.

Most helpful comment

Fragments are started at keyframes. If keyframes are rare, that's what you get. Try using the -g option of ffmpeg.

All 2 comments

@arut , It would be great if you could spare sometime to help me with this :)

Fragments are started at keyframes. If keyframes are rare, that's what you get. Try using the -g option of ffmpeg.

Was this page helpful?
0 / 5 - 0 ratings