Getting ffmpeg and zoneminder working together correctly.

Support and queries relating to all previous versions of ZoneMinder
Locked
hushpuppy
Posts: 147
Joined: Wed Aug 08, 2007 10:28 am

Getting ffmpeg and zoneminder working together correctly.

Post by hushpuppy »

There seems to be huge issues getting ffmpeg to work correctly.
To date I've managed to get video generation to work, but mpg streaming totally refuses to work.
This was with a Debian system, and i installed the debs (etch).

After a day or so messing around, and reading numerous posts about similar problems, i decided to compile ffmpeg from source, this in itself presented hurdles.

I therefore decided to post this, with my attempts so far, and will update as neccessary, any success, hopefully this will help others, as any info is scattered all around the forum, any input greatly appreciated.

1) You need syn - apt-get install subversion

2) svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

3) cd ffmpeg

4) ./configure --enable-gpl --enable-swscale --prefix=/usr
** NOTE may need --with-shared as well, my first attempt though is as above.

5) make install

6) make installlib
NOTE - All instructions i found said you have to do #6 as above, yet when i tried, i got "no rule to make" error, i searched for libavformat.a , and it is installed in /usr/lib, so decided to press on.

7) /usr/bin/ffmpeg -version

----------output -----------

--------- end of output ---

8) into zoneminder source dir, and configure like this
./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin --with-ffmpeg=/usr/bin --with-webuser=www-data --with-webgroup=www-data ZM_SSL_LIB=openssl

9) make install
Gave me the following errors
zm_mpeg.h:29:29: error: ffmpeg/avformat.h: No such file or directory
zm_mpeg.h:31:28: error: ffmpeg/swscale.h: No such file or directory

10) fix zm_mpeg.h - make the following changes
Line 29 should read like this
#include <libavformat/avformat.h>
Line 31 should read #include <libswscale/swscale.h>
Note, could be line 32, just makle sure the define for libscscale reads as above.
Save your changes and exit your editor.

11) make install
This time zm compiled, and thats where i'm at right now, will report back.
Does anyone have any input on this, any suggestions ?
hushpuppy
Posts: 147
Joined: Wed Aug 08, 2007 10:28 am

Post by hushpuppy »

Burn a new iso, and booted it, tried streaming mpeg, still having problems.

No errors in zm logs, but apache error log has this.

[Wed Aug 20 14:13:43 2008] [error] [client 192.168.1.2] [mpeg1video @ 0xfd29f20], referer: http://192.168.1.10/zm/index.php?view=w ... 0&control=
[Wed Aug 20 14:13:43 2008] [error] [client 192.168.1.2] MPEG1/2 does not support 2/1 fps, referer: http://192.168.1.10/zm/index.php?view=w ... 0&control=


Does streaming mpeg actually work ?.
hushpuppy
Posts: 147
Joined: Wed Aug 08, 2007 10:28 am

Post by hushpuppy »

mpeg streaming is working, sort of, it can take a while for the stream to actually show itself, thats over wireless link.

swf streaming appears to work.

mpeg generation appears to work.

Sorry for the appears, but currently it's dark and the only cam i have connected to a test machine doesnt do IR.

In any case, this is how i managed it.
I used ffmpeg-0.4.8
On debian etch it doesnt compile easily, i had to install gcc-3.3 ( apt-get install gcc-3.3), as later versions of gcc give an error.

Then ./configure --cc=gcc-3.3 --enable-gpl --enable-swscale --enable-shared --prefix=/usr
then make install / make installlib

rebuilt zoneminder.
rebuilt iso
burnt cd
tested

Hope this helps, and the functionality will ship with the next version (early next week)

In a nutshell, the current version of ffmpeg gives me problems, possibly due to the low frame rate of my hardware, but i can build an iso with the latest ffmpeg if anyone would like to try it with better video hardware. Just ask.
johnc10
Posts: 15
Joined: Wed Aug 10, 2005 9:28 pm

Post by johnc10 »

Fedora 9
ffmpeg -v
FFmpeg version SVN-r15876, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-swscale --prefix=/usr
libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 3. 0 / 52. 3. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
built on Nov 18 2008 23:17:10, gcc: 4.3.0 20080428 (Red Hat 4.3.0-8)

Downloaded and compiled ffmpeg as above( though do make then sudo make install).

cd ZoneMinder-1.23.3

Edit src/zm_ffmpeg.h and line 29 add /libavformat/ and line 31 add /libswscale/ directories :-

#define __STDC_CONSTANT_MACROS
#include <ffmpeg/libavformat/avformat.h>
#if HAVE_LIBSWSCALE
#include <ffmpeg/libswscale/swscale.h>
#endif // HAVE_LIBSWSCALE

Fedora 10 had more path errors for the ffmpeg rpm plus SElinux erors preventing ffmpeg running.

sudo chcon -t textrel_shlib_t '/usr/lib/sse2/libswscale.so.0.6.1'
sudo chcon -t textrel_shlib_t '/usr/lib/sse2/libpostproc.so.51.2.0'

ffmpeg -v
FFmpeg version SVN-r15261, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i386 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables --enable-libdc1394 --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avfilter-lavf --enable-postproc --enable-swscale --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-optimizations --disable-stripping --shlibdir=/usr/lib --cpu=i386 --disable-amd3dnow --disable-mmx --disable-sse
libavutil 49.10. 0 / 49.10. 0
libavcodec 51.71. 0 / 51.71. 0
libavformat 52.22. 1 / 52.22. 1
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 1. 0 / 0. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Nov 20 2008 14:37:49, gcc: 4.3.2 20081105 (Red Hat 4.3.2-7)

Update each file with full path :-
sudo vim /usr/include/ffmpeg/libavformat/avformat.h
#include "/usr/include/ffmpeg/libavcodec/avcodec.h"
sudo vim /usr/include/ffmpeg/libavcodec/avcodec.h
#include "/usr/include/ffmpeg/libavutil/avutil.h"
sudo vim /usr/include/ffmpeg/libswscale/swscale.h
#include "/usr/include/ffmpeg/libavutil/avutil.h"


Configure and compile as normal. Then install.
./configure --with-mysql=/usr --with-webdir=/var/www/html/zm --with-cgidir=/var/www/cgi-bin --with-ffmpeg=/usr/bin --with-lame=/usr/lib --with-webuser=apache --with-webgroup=apache

make
sudo make install
Last edited by johnc10 on Fri Mar 06, 2009 10:36 pm, edited 4 times in total.
kevin_robson
Posts: 247
Joined: Sun Jan 16, 2005 11:26 am

Post by kevin_robson »

The problem with ffmpeg is it changes so much. COuld you both post which version you checked out for others in the future. Otherwise a helpful post which I'll probably need in a couple of weeks - thanks.
Guard
Posts: 2
Joined: Wed Nov 19, 2008 7:28 am

Post by Guard »

With ffmpeg (on Slackware) i have compiled it with extra option
--disable-bzlib (disabling bzlib removes error about missing headers from bzlib.h which i have in my system and even more - i have told ffmpeg to use it directly from my path - no way to compile :() - then ffmpeg compiles correctly. I don't know if bzlib is used by ZoneMidnder but till today there were no errors in logs about bzlib.
Locked