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
RTSP Protocol Documentation indicates there is timeout option. I'd try:
ffmpeg -rtsp_transport tcp -stimeout 3000 -y -i "rtsp://192.168.64.101" ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With