Closed tosiara closed 10 months ago
Here is how to patch ffmpeg and force camera to TCP to workaround a non-compliant RTSP camera Related: https://github.com/Motion-Project/motion/issues/1071, https://sourceforge.net/p/motion/mailman/message/58717607/
git clone https://github.com/ffmpeg/ffmpeg
cd ffmpeg
wget https://raw.githubusercontent.com/eusoubrasileiro/motion_server_nvr/jetson-nano/ansible/roles/jnano/files/RTSP_lower_transport_TCP.patch
git apply < RTSP_lower_transport_TCP.patch
sudo apt-get install yasm lib264-dev
./configure --prefix=/full/path/to/ffmpeg/out --enable-gpl --enable-libx264
make -j4
make install
cd ..
git clone https://github.com/Motion-Project/motion
cd motion
sudo apt-get -y install autoconf automake build-essential pkgconf libtool libzip-dev libjpeg-dev libwebp-dev libmicrohttpd-dev autopoint
sudo apt-get remove libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev
autoreconf -fiv
./configure --with-ffmpeg=/full/path/to/ffmpeg/out
make
./src/motion -c your_config.conf -d 9 -n
Nice. Whats the downsize of doing it this way? It seems like out of the box, motion does not support h.264 codec.
Packaged Motion uses ffmpeg libs to decode H264 and it comes out of the box. It's only a problem with some non-compliant cameras that require a custom ffmpeg build with a workaround to force TCP
After writing the comment, I figured that mkv for example is h264 encoded, so that worked. Sorry for the irrelevant weight to the issue.
Can you explain this issue more? Generally, we don't want UDP we want rtsp_transport tcp
and this can be specified via the Motion option of netcam_params. (It is actually already the default). I didn't think that any such patch to ffmpeg was required. Simply specify it as the option instead of UDP.
For general issues with the camera not being detected or failing to analyze, the solution is usually to lower the camera GOP/I-Frame interval.
The issue here is that ffmpeg out of the box tries to follow RTSP protocol. The camera in turn, supports TCP, but does not advertise it correctly, and motion fails to connect since motion forces TCP by default (perfectly explained by @eusoubrasileiro at https://stackoverflow.com/questions/66280861/ffmpeg-nonmatching-transport-in-server-reply-but-openrtsp-works)
There are two workarounds here.
I'm still not following the issue/problem for Motion to resolve. Is this just a FYI/"How to" for those that have one of these cameras?
Yes, this was more like FYI for everyone as there were many users affected
Did you read the guide?
Yes
What is the base version number of Motion being used?
4.6.x
What was the install method?
Installed via package tool
What is base architecture?
x86
What is the distro being used?
Ubuntu
Disto version number
22.04
Camera type(s) being used?
Network camera with RTSP
Describe the issue/problem and steps to reproduce
Motion fails with error:
The same error is given by ffprobe:
However, the newer ffmpeg is able to read the stream:
Motion log output at log_level 8