viseron
viseron copied to clipboard
Jetson Nano rtsp: ffmpeg "Cannot assign requested address"
tldr; ffmpeg version n4.2.2-15-g6878ea5a44
contains this bug which means it dies with rtsp streams if -timeout
is used. Viseron uses -timeout
:-)
If you Google this you will find advice to replace -timeout <seconds>
with -stimeout <microseconds>
, which works up until 5.x
when the ffmpeg devs decided to rename -timeout
to -listen_timeout
, and -stimeout
to -timeout
.
option 1: Upgrade to ffmpeg 5.x
option 2: Replace the use of -timeout 5000000
with -stimeout 5000000
, worry about ffmpeg 5 later.
Note that -timeout is measured in seconds, so, if it worked, the timeout would be 58 days :-)
Here are some logs:
[2023-06-03 15:46:08] [DEBUG ] [viseron.components.ffmpeg.camera.camera_1] - Starting capture thread
[2023-06-03 15:46:08] [DEBUG ] [viseron.watchdog] - Registering <RestartableThread(viseron.camera.camera_1, initial daemon)> in the watchdog
[2023-06-03 15:46:08] [DEBUG ] [viseron.components.ffmpeg.stream.camera_1] - FFmpeg decoder command: ffmpeg_camera_1 -hide_banner -loglevel error -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts -use_wallclock_as_timestamps 1 -vsync 0 -timeout 5000000 -c:v h264_nvv4l2dec -rtsp_transport tcp -i rtsp://*****:*****@192.168.1.66:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy -c:a copy /segments/camera_1/%Y%m%d%H%M%S.mp4 -vf fps=1.0 -f rawvideo -pix_fmt nv12 pipe:1
[2023-06-03 15:46:08] [INFO ] [viseron.components.nvr.nvr.camera_1] - NVR for camera DrivewayCam initialized
[2023-06-03 15:46:08] [INFO ] [viseron.components] - Setup of domain nvr for component nvr with identifier camera_1 took 0.0 seconds
[2023-06-03 15:46:08] [DEBUG ] [viseron.states] - Setting state of toggle.camera_1_connection to state: on, attributes {'name': 'DrivewayCam Connection', 'domain': 'toggle'}
[2023-06-03 15:46:08] [ERROR ] [viseron.components.ffmpeg.stream.camera_1] - [rtsp @ 0x55961df8f0] Unable to open RTSP for listening
[2023-06-03 15:46:08] [ERROR ] [viseron.components.ffmpeg.stream.camera_1] - rtsp://*****:*****@192.168.1.66:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif: Cannot assign requested address
[2023-06-03 15:46:08] [ERROR ] [viseron.components.ffmpeg.camera.camera_1] - FFmpeg process has exited
The full ffmpeg information:
ffmpeg version n4.2.2-15-g6878ea5a44 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --enable-nvv4l2dec --enable-libv4l2 --enable-shared --extra-libs='-L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils' --extra-cflags='-I /usr/src/jetson_multimedia_api/include/'
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
Also, an explanation of the 'timeout' renaming saga.
I have a work-around. Add the following to the ffmpeg config for your camera:
ffmpeg:
camera:
camera_1:
name: DrivewayCam
...
input_args:
- "-timeout"
- "0"
- "-stimeout"
- "5000000"
It's been a tonne of work, and I've learned a lot. Now it's time to try out Viseron and see if I like -- I sure hope so!
Finally, I just noticed here, that "The Jetson Nano support is very limited in FFmpeg. If you have a Nano i suggest looking at the gstreamer component instead."
Ooops.
See also Bug #108
Wow thats a real Sherlock Holmes investigation that you've conducted, thanks!
The Jetson Nano version will stay at 4.2.2 since it is installed from apt
.
The other containers have FFmpeg 5.1.2.
Will make sure to fix this in a coming release. Thanks again!