bluecherrydvr / bluecherry-apps

Bluecherry surveillance system (server application)
http://www.bluecherrydvr.com
GNU General Public License v2.0
200 stars 64 forks source link

Prefer TCP again #658

Closed andrey-utkin closed 4 months ago

andrey-utkin commented 5 months ago

This changes the behaviour of "Protocol" option of device configuration, which affects how the source RTSP stream is being consumed.

Historically, TCP was preferred. Then, since 01bac09d5caf ("Refactored input device and added option to select AUTO rtp protocol") UDP with fallback to TCP became the default ("AUTO" mode). This makes picture in recordings prone to smearing, so it was decided to switch back to TCP by default.

Previously, fallback to TCP was done in our code; this commit makes use of FFmpeg's "rtsp_flags=+prefer_tcp" which accomplishes suitable behaviour: try TCP, fallback to UDP.

andrey-utkin commented 5 months ago

Tested on Ubuntu 22.04 (Jammy) manually, works as expected.

A way to inspect how the stream is being transmitted is to run

ngrep -t -e -d any tcp  and 'src host' $CAMERA_IP
ngrep -t -e -d any udp  and 'src host' $CAMERA_IP

both at the same time, and see where the traffic happens.

There is an existing bug that switching "Protocol" setting requires a service restart (systemctl restart bluecherry), we'll get to that separately.