[FFmpeg-user] Timeout on receiving data from rtsp server

Michael Kohne mhkohne at moberg.com
Fri Apr 12 16:17:28 EEST 2019

I'm using ffmpeg to transcode data from a Sony IP camera (the EP-580, h.264
video, G.711 audio) via rtsp, and I'd like ffmpeg to timeout and exit
relatively quickly (1 or 2 seconds) if the camera stops sending data. This
setup is only going to be used on a local network, so that small timeout is
perfectly reasonable.

I'm using the latest ffmpeg for these tests.

When I disconnect the camera from the network, I get 'Connection timed out'
messages at 20 second intervals until finally it gives up after 8 or 9 of
those messages and ffmpeg exits.

I tried playing with -stimeout, but it doesn't seem to have any effect,
which probably means I don't understand what it's supposed to do.

Is there some way to gain control over these timeouts?


command line:
ffmpeg_g -loglevel info -min_port 62000 -max_port 62004 -i rtsp://
admin:admin at -y -max_muxing_queue_size 1024
-codec:v mpeg4 -codec:a ac3 -ar 44100 /data/PatientData/vidtmp/test.avi

ffmpeg version N-93562-g3e10223 Copyright (c) 2000-2019 the FFmpeg
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
  configuration: --prefix=/data/HEAD/ffmpeg/build
--extra-ldflags=-L/data/HEAD/ffmpeg/build/lib --extra-libs='-lm -ldl
-lpthread -lrt' --enable-gpl --enable-nonfree --disable-libfdk_aac
--enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
--enable-libfreetype --enable-libspeex --enable-libtheora --cpu=i686
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 50.100 / 58. 50.100
  libavformat    58. 27.102 / 58. 27.102
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
ESC[0;33mGuessed Channel Layout for Input Stream #0.1 : mono
ESC[0mInput #0, rtsp, from 'rtsp://admin:admin@':
    title           : SONY RTSP Server
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 800x600, 30
fps, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> ac3 (native))
Press [q] to stop, [?] for help
Output #0, avi, to '/data/PatientData/vidtmp/test.avi':
    INAM            : SONY RTSP Server
    ISFT            : Lavf58.27.102
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(progressive),
800x600, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
      encoder         : Lavc58.50.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, mono, fltp, 96
      encoder         : Lavc58.50.100 ac3
frame=   36 fps=0.0 q=2.9 size=      10kB time=00:00:15.32 bitrate=
5.2kbits/s speed=30.5x    ^Mframe=   51 fps= 50 q=3.8 size=      10kB
time=00:00:16.09 bitrate=   4.9kbits/s speed=15.7x    ^Mframe=   67 fps= 44
q=2.7 size=     266kB time=00:00:16.57 bitrate= 131.3kbits/s speed=10.8x
^Mframe=   83 fps= 40 q=3.1 size=     266kB time=00:00:17.06 bitrate=
127.5kbits/s speed=8.25x    ^Mframe=   97 fps= 38 q=2.3 size=     266kB
time=00:00:17.65 bitrate= 123.3kbits/s speed=6.87x    ^Mframe=  114 fps= 37
q=3.1 size=     266kB time=00:00:18.14 bitrate= 119.9kbits/s speed=5.85x
^MESC[1;31mrtsp://admin:admin@ Connection timed
ESC[0mframe=  128 fps=9.4 q=3.7 size=     266kB time=00:00:18.63 bitrate=
116.8kbits/s speed=1.37x    ^MESC[1;31mrtsp://
admin:admin at Connection timed out
ESC[0mframe=  129 fps=5.5 q=3.6 size=     266kB time=00:00:18.63 bitrate=
116.8kbits/s speed=0.789x    ^MESC[1;31mrtsp://
admin:admin at Connection timed out
ESC[0mframe=  130 fps=3.9 q=3.4 size=     266kB time=00:00:18.63 bitrate=
116.8kbits/s speed=0.554x    ^MESC[1;31mrtsp://
admin:admin at Connection timed out
ESC[0mframe=  131 fps=3.0 q=4.6 size=     266kB time=00:00:18.63 bitrate=
116.8kbits/s speed=0.427x    ^MESC[1;31mrtsp://
admin:admin at Connection timed out
ESC[0mframe=  132 fps=2.5 q=4.4 size=     266kB time=00:00:18.63 bitrate=
116.8kbits/s speed=0.347x    ^MESC[1;31mrtsp://
admin:admin at Connection timed out

Michael Kohne

Senior Software Engineer
Office: 215.283.0860 x208
mhkohne at moberg.com


Celebrating 20 Years

Transforming Neurocritical Care

Research, Inc.

224 S Maple Street, Ambler, PA 19002

24/7 Customer 
Support: 888.662.7246

www.moberg.com <https://www.moberg.com/>

More information about the ffmpeg-user mailing list