ffmpegudpvideo-streamingvlcdvb

FFMPEG: How to keep UDP stream connection open even source drop some minute


i decode UDP stream (that genrate from DVB signal) using ffmpeg to HLS with this code :

ffmpeg -i udp://239.1.2.1:60001?fifo_size=50000000 -acodec copy -vcodec copy -hls_time 2 -hls_wrap 5 -f hls /var/www/html/ts/1.m3u8

Sometime DVB signal drop for some second or minute and that lead to ffmpeg stop encoding and show error :

udp://239.1.2.1:60001: Connection timed out

When i play udp in VLC player and input stream drop for some second VLC wait stop play and when stream start again play again.

Now i want to know is there exist a way that ffmpeg either found that stream stop and dont show timeout error...it mean that FFMPEG keep connection open and wait for receive stream every time start from source. Thanks


Solution

  • For UDP streams you can set timeout like:

    ffmpeg -timeout 2000 -i udp://239.1.2.1:60001?fifo_size=50000000
    

    For RTP steams you can set timeout like:

    ffmpeg -timeout 2000 -i rtp://192.168.0.12:1234 
    

    For RTSP streams you can specify timeouts in the SDP file