[WORKAROUND] "Smearing" on H.264 RTSP Cameras

Forum for questions and support relating to the 1.26.x releases only.
Posts: 2
Joined: Mon Apr 14, 2014 2:50 pm

Re: [WORKAROUND] "Smearing" on H.264 RTSP Cameras

Post by hre1 » Mon May 26, 2014 2:16 pm

Really no hints what to do to compile 1.27.1 with the patch successfully...? :shock: :shock: :shock:

Code: Select all

arm-linux-gnueabi-g++ -DHAVE_CONFIG_H -I. -I..  -I/usr/include -I/usr/include -D__STDC_CONSTANT_MACROS -Wall -finline-functions -fomit-frame-pointer -I/usr/include -D__STDC_CONSTANT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_CONSTANT_MACROS -DHAVE_LIBCRYPTO -MT zm_ffmpeg_camera.o -MD -MP -MF .deps/zm_ffmpeg_camera.Tpo -c -o zm_ffmpeg_camera.o zm_ffmpeg_camera.cpp
zm_ffmpeg_camera.cpp: In member function ‘virtual int FfmpegCamera::Capture(Image&)’:
zm_ffmpeg_camera.cpp:128:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
zm_ffmpeg_camera.cpp:133:17: error: ‘av_err2str’ was not declared in this scope
zm_ffmpeg_camera.cpp:136:17: error: ‘av_err2str’ was not declared in this scope
make[3]: *** [zm_ffmpeg_camera.o] Error 1
make[3]: Leaving directory `/usr/local/src/zoneminder/ZoneMinder/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/zoneminder/ZoneMinder'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/src/zoneminder/ZoneMinder'
dh_auto_build: make -j1 returned exit code 2
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2

Posts: 14
Joined: Mon Apr 23, 2012 5:15 pm

Re: [WORKAROUND] "Smearing" on H.264 RTSP Cameras

Post by cambot » Wed Jun 04, 2014 4:14 am

Hey, just thought I'd post to some folks out there who are still struggling with applying this patch.

I also have the "smearing" issue because of the UDP bug in Ubuntu. I'm running Ubuntu Server 14.04 LTS 64-bit and the default Zoneminder package is 1.26.5.

In order to get a patched binary, here is what I did:

mkdir ~/workdir
cd ~/workdir
# Download the attached patch file into this directory somehow.
# Get the original package installed so you have all dependencies
sudo apt-get install zoneminder
# Download sources
apt-get source zoneminder
cd zoneminder-1.26.5
# Get build dependencies
sudo apt-get build-dep zoneminder
# Test the build
fakeroot debian/rules binary
# Clean up for next run
fakeroot debian/rules clean
# Apply the patch
cp ~/workdir/rtsp_tcp_only.diff debian/patches
# Edit debian/patches/series and add rtsp_tcp_only.diff to the end of that file.
# Apply all patches
quilt push -a
# Do the real build with the patched file
fakeroot debian/rules binary
# now re-install the package; you might want to save the file for future re-installation too.
sudo dpkg -i ../zoneminder_1.26.5-1ubuntu3_amd64.deb

The patch file is attached to this post.
EDIT: I have no idea what attachments aren't working, so I'm trying to put this tiny patch in-line as code:

Code: Select all

Index: zoneminder-1.26.5/src/zm_ffmpeg_camera.cpp
--- zoneminder-1.26.5.orig/src/zm_ffmpeg_camera.cpp	2014-06-03 19:41:29.000000000 -0700
+++ zoneminder-1.26.5/src/zm_ffmpeg_camera.cpp	2014-06-03 19:44:26.353282233 -0700
@@ -115,7 +115,9 @@
     if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 )
-    if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 )
+    AVDictionary *opts = 0;
+    av_dict_set(&opts, "rtsp_transport", "tcp", 0);
+    if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) !=0 )
         Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) );
Also, to echo what other people have said, a couple of hints:

You do need to make sure that you do not limit the framer rate in Zoneminder. Go into the camera itself and set the frame limit there. My suggestion is to leave the frame rate unlimited at first then open Zoneminder up in Monitor mode and watch the frame rate. If you get something like 30fps, then back it down a little bit to give yourself a little breathing room and the stream will be much more reliable. I tend to stick with 10 fps for all of my Axis and Vivotek cameras.

You can use tcpdump to verify that your traffic is actually using TCP instead of UDP.

For example, if your cameras are all on eth1 network interface, do:

tcpdump -nn -i eth1 'not host'

Posts: 51
Joined: Tue Feb 11, 2014 1:04 pm

Re: [WORKAROUND] "Smearing" on H.264 RTSP Cameras

Post by kenworth » Wed Jun 11, 2014 1:19 pm

I have noticed that there appears to be a patch in the current 1.27.1 source for this problem. In FfmpegCamera::PrimeCapture() class in zm_ffmpeg_camera.cpp, I noticed the following code:

// Set transport method as specified by method field, rtpUni is default
if ( Method() == "rtpMulti" )
else if ( Method() == "rtpRtsp" )
else if ( Method() == "rtpRtspHttp" )

So if you select RTP/RTSP as the Remote Method in the Source tab, it should force TCP. I tried this and verified that it does with a Wireshark trace....my smearing issues have disappeared on 3 different cameras as a result.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest