Masoud
Masoud

Reputation: 1351

Nginx RTMP segments filename with timestamp

I have a Nginx RTMP hls server for live streaming, and the file names are like 'streamkey-0.tst, streamkey-1.ts, streamkey-2.ts ...'
But I want that the segments to not start with number from zero, but start with current timestamp like 'streamkey-142134122.ts, streamkey142134126.ts ...'
Is there a solution for this issue? Thank you

Upvotes: 0

Views: 1365

Answers (1)

Grégory
Grégory

Reputation: 126

You should add hls_fragment_naming timestamp in your HLS section. Example :

rtmp {
    server {
        listen 1935;
    
        application src {
            live on;

            exec ffmpeg -i rtmp://localhost/src/$name
              -c:a aac -b:a 32k  -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_low
              -c:a aac -b:a 64k  -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid
              -c:a aac -b:a 128k -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi;
        }

        application hls {
            live on;

            hls on;
            hls_path /tmp/hls;
            hls_fragment_naming timestamp; # HERE

            hls_variant _low BANDWIDTH=160000;
            hls_variant _mid BANDWIDTH=320000;
            hls_variant _hi  BANDWIDTH=640000;
        }
    }
}

For more informations : https://github.com/arut/nginx-rtmp-module/wiki/Directives#hls_fragment_naming

Upvotes: 1

Related Questions