Search code examples
ffmpegstreamvideo-streaminghttp-live-streaming

ffmpeg dont change time duration


I tried to convert a UDP stream (that genrated from DVB signal) to HLS m3u8 file with this code:

ffmpeg -i udp://239.1.2.1:60001 -acodec aac -strict -2 -vcodec libx264 -hls_wrap 100 -f hls /var/www/html/ts/1.m3u8 

and output m3u8 file is :

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:66
#EXTINF:0.960000,
21.ts
#EXTINF:2.080000,
22.ts
#EXTINF:2.400000,
23.ts
#EXTINF:1.760000,
24.ts
#EXTINF:2.080000,
20.ts

I tried to change the target duration to 10 in this file with the option -segment_time 10 but the target duration doesn't change in m3u8 file, can anybody help me with this problem?


Solution

  • I solve this problem with code:

    ffmpeg -i udp://239.1.2.4:60004?fifo_size=50000000 -acodec copy -vcodec copy -preset ultrafast -flags -global_header -f hls -hls_time 20 -hls_wrap 5 /var/www/html/ts/4.m3u8
    

    Add this option to ffmpeg fix problem

    -preset ultrafast -flags -global_header