Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg timeout with rtsp

Tags:

ffmpeg

rtsp

I have script that capture image from wifi camera with ffmpeg. It works fine until camera is not reachable due to network troubles. The script stuck in ffmpeg capture and never exit. Is it possible to have some kind of timeout? -stimeout (in miliseconds) seems not working.

There is part of script that capture images. (there are some manipulation after that)

#!/bin/bash
week="$(date '+%Y_%U')"
ts="$(date '+%Y-%m-%d_%H:%M:%S')"
ffmpeg -rtsp_transport tcp -y -i "rtsp://192.168.64.101" -frames:v 1 $week/$ts.jpg -stimeout 3000 -y

I did test on other camera and results are:

ffmpeg -y -i "rtsp://192.168.64.112:8554/profile0" -frames:v 1 Ilatest.jpg

Does work OK, but with timeout of 5 seconds as

ffmpeg -timeout 5000000 -y -i "rtsp://192.168.64.112:8554/profile0" -frames:v 1 Ilatest.jpg

doesn't and I got error report as:

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
...
...
[rtsp @ 0x55d250488740] Unable to open RTSP for listening
rtsp://192.168.64.112:8554/profile0: Cannot assign requested address
like image 378
eSlavko Avatar asked Oct 25 '25 01:10

eSlavko


1 Answers

RTSP Protocol Documentation indicates there is timeout option. I'd try:

ffmpeg -rtsp_transport tcp -stimeout 3000 -y -i "rtsp://192.168.64.101" ...
like image 188
kesh Avatar answered Oct 27 '25 00:10

kesh