Page 1 of 2

mpeg camera's in zoneminder 1.23.3 using ffmpeg

Posted: Thu Nov 13, 2008 9:57 pm
by gertjan
I have seen there is support for mpeg4 camera's in the next version, but i have made an replacement zm_remote_camera.cpp for ZoneMinder 1.23.3 using ffmpeg for decoding, but also for the network part.

As a bonus it gives me a lower load on the mjpeg camera's i am using at the moment.

http://dejonge.tv/archives/17

regards,
Gert-Jan

Re: mpeg camera's in zoneminder 1.23.3 using ffmpeg

Posted: Thu Nov 13, 2008 11:07 pm
by curtishall
Neat stuff.


gertjan wrote:I have seen there is support for mpeg4 camera's in the next version, but i have made an replacement zm_remote_camera.cpp for ZoneMinder 1.23.3 using ffmpeg for decoding, but also for the network part.

As a bonus it gives me a lower load on the mjpeg camera's i am using at the moment.

http://dejonge.tv/archives/17

regards,
Gert-Jan

Re: mpeg camera's in zoneminder 1.23.3 using ffmpeg

Posted: Tue Nov 18, 2008 2:21 pm
by zoneminder
gertjan wrote:I have seen there is support for mpeg4 camera's in the next version, but i have made an replacement zm_remote_camera.cpp for ZoneMinder 1.23.3 using ffmpeg for decoding, but also for the network part.

As a bonus it gives me a lower load on the mjpeg camera's i am using at the moment.

http://dejonge.tv/archives/17

regards,
Gert-Jan
This is very impressive. I will take a good look at this as you may well have found a better way of doing it provided ffmpeg supports all the other little wrinkles. :D

Re: mpeg camera's in zoneminder 1.23.3 using ffmpeg

Posted: Tue Nov 18, 2008 6:47 pm
by gertjan
zoneminder wrote: This is very impressive. I will take a good look at this as you may well have found a better way of doing it provided ffmpeg supports all the other little wrinkles. :D
What i noticed up to now:
* it takes quite a few seconds before the cam is initialized and streaming
* mjpg cameras work best by adding a dummy ?/&.mjpg at the end of the url

Posted: Tue Nov 18, 2008 8:53 pm
by Normando
Thank you Gert Jan for this hack ;)

A few changes I was made to the file are:
Please, replace every SLASH word with / and DOT with . because forum striped this characters

From:

Code: Select all

extern "C" {
#include <libavcodecSLASHavcodecDOTh>
#include <libavformatSLASHavformatDOTh>
#include <libswscaleSLASHswscaleDOTh>
}
To:

Code: Select all

extern "C" {
#include <ffmpegSLASHavcodecDOTh>
#include <ffmpegSLASHavformatDOTh>
#include <ffmpegSLASHswscaleDOTh>
}




And just above the above lines (extern "C") I was added these lines:

Code: Select all

#define INT64_C
#define __STDC_CONSTANT_MACROS
#include <stdintDOTh>
because I get INT64_C errors:

http://ilab.usc.edu/cgi-bin/yabb/YaBB.p ... 1173913186

Posted: Tue Nov 18, 2008 9:13 pm
by Normando
I can compile but I can't test because I have a remote camera with a password.

I have found a few mpeg4 free cameras to test:

http://www.midisec.com/index.php?option ... &Itemid=55

So, at Hostname I use:
demo:demo@midisec.com

Port:
2010

Source:
rtsp://midisec.com/live.sdp

Is this correct?

BTW: If ffmpeg support mpeg4, with x264 library it will support H.264 decoding?

Posted: Tue Nov 18, 2008 10:44 pm
by gertjan
Normando wrote:I can compile but I can't test because I have a remote camera with a password.

I have found a few mpeg4 free cameras to test:

http://www.midisec.com/index.php?option ... &Itemid=55

So, at Hostname I use:
demo:demo@midisec.com

Port:
2010

Source:
rtsp://midisec.com/live.sdp

Is this correct?

BTW: If ffmpeg support mpeg4, with x264 library it will support H.264 decoding?
At this moment, the code does not actively use the port or the host part. My best geuss is to test with the ffmpeg commandline player (ffplay) use f.e.:
ffplay rtsp://midisec.com/live.sdp
ffplay rtsp://midisec.com:2010/live.sdp
ffplay rtsp://demo:demo@midisec.com:2010/live.sdp

my hope is indeed to be able to also read h264 cameras but i have no h264 camera to test.

Posted: Wed Nov 19, 2008 5:52 pm
by gertjan
I have checked a "Digi-Lan CMOS network camera LAN" TV7203 which I believe is based on the same firmware as the vivo camera's.

ffplay rtsp://x.x.x.x/live.sdp works fine (this is what i use in my own setup)
ffplay rtsp://x.x.x.x:2010/live.sdp works fine
ffplay rtsp://demo:demo@x.x.x.x:2010/live.sdp gives errors in the header.

So at the moment you should be able to access camera's on non default ports. but at least with rtsp username/password does not work.

you can also try openRTSP to first receive the camera:
openRTSP -b 80000 -c -d 60 -v -u demo demo rtsp://midisec.com:2010/live.sdp

I have tried all the cameras on the list on the midisec site, but i cannot receive any of them unfortunately.

see also http://www.zoneminder.com/forums/viewtopic.php?t=11475

extra method for rtsp cameras

Posted: Tue Dec 02, 2008 9:03 pm
by gertjan
At this moment i see some problems with the rtsp code as used in ffmpeg.

best solution to use rtsp camera's at the moment is the openRTSP work around:
1. create a pipe ( f.e. mkpipe /tmp/pipes/achterterrein.pipe )
2. change owner of pipe to the user you use for running zoneminder (f.e. chown nobody /tmp/pipes/achterterrein.pipe )
3. use the path to the pipe as input path for the camer, enter camera ip en port number dummy values.
4. start openRTSP to stream video to the pipe

I put my openRTSP commands in the inittab, so they are automatically restarted, check your own camera's so your buffer is large enough:
g1:3:respawn:/usr/bin/openRTSP -t -b 40000 -v rtsp://x.x.x.x/mpeg4/media.amp > /tmp/pipes/achterterrein.pipe
g2:3:respawn:/usr/bin/openRTSP -t -b 100000 -v rtsp://x.x.x.x/live.sdp > /tmp/pipes/mpeg4.pipe
g3:3:respawn:/usr/bin/openRTSP -t -b 100000 -v rtsp://x.x.x.x/live.sdp > /tmp/pipes/lesruimte.pipe


With this work around I have al my rtsp cameras working like a charm. With openRTSP you can also add username and password [-u <username> <password>].

camera's working for me at the moment:
axis 2120, http://x.x.x.x/mjpg/video.mjpg?resoluti ... ps=5&.mjpg
axis 2110, http://x.x.x.x/mjpg/video.mjpg?resoluti ... &fmt=.mjpg
axis 2100, http://x.x.x.x/mjpg/video.mjpg?resolution=640x480&.mjpg
axis 210, rtsp://x.x.x.x/mpeg4/media.amp best via openRTSP workaround
Mobotix M1, http://x.x.x.x/cgi-bin/faststream.jpg?.mjpg
Abus T7204 & T7203, rtsp://x.x.x.x/live.sdp best via openRTSP workaround
Sony SNC-M3W, http://x.x.x.x/img/video.asf
AVTECH AVI203 h264 cam, rtsp://x.x.x.x/live/h264 best via openRTSP workaround

Hope this helps
regards,
Gert-Jan

Re: extra method for rtsp cameras

Posted: Tue Dec 02, 2008 9:15 pm
by Normando
gertjan wrote: (yet unkown brand) h264 cam, rtsp://x.x.x.x/live/h264 best via openRTSP workaround
This camera is AVTECH AVI203
Do you try mpeg4 from avtech? the url is /live/m.peg4 <- see the dot
Other mothels from avtech like AVI201 use /live/mpeg4 without the dot.

I have try mpeg4, but allway I see the scrren splitted by two. Strange, but I will test again.

Thank you Gert Jan for your work.

Posted: Tue Dec 02, 2008 9:30 pm
by gertjan
I indeed also see a split screen with the mpeg4, i have not seen such behaviour before. I'll try some checks to see if it is camera or ffmpeg related.

Posted: Tue Dec 02, 2008 9:37 pm
by Normando
The same issue happens with an AVI201 camera (mpeg4 only camera), but no happens if I set the stream directly to quicktime :(

I suspect this is a camera issue, but why run ok in quicktime?


EDIT: I forgot to say this happen using vpipe and vloopback either

Posted: Fri Jan 23, 2009 3:43 pm
by zoneminder
I thought you might be interested that the latest release candidate for 1.24.0 now includes an ffmpeg monitor type which essentially implements a similar process to that described above in that any path can be assigned and that is passed directly to ffmpeg for processing. Please see the last post in this thread for details. Thanks to gertjan for his original post which was part of the inspiration for this.

Also I submitted a patch to ffmpeg to permit urls with authentication of the form of user:pass@hostname/path to be correctly authenticated which should fix some of the issues described in earlier posts. The patch has now been accepted and should be available in the latest ffmpeg via svn.

ffmpeg in last 1.24.0

Posted: Mon Jan 26, 2009 9:07 am
by gertjan
Wow this is great news,

I am quite busy at the moment, but i'll give it a try asap.

Posted: Mon Feb 02, 2009 11:58 am
by Hex
Gentlemen, forgive me for being new to the ZoneMinder (i.e. asking stupid questions), but how do I exactly use this in an already compiled version, such as the one used in Ubuntu (from reps)?

I have a camera with an mjpegb (yuvj422p) stream that I can view with ffmpeg/ffplay. Since using mjpeg gives me twice as good fps than using a static jpg path, I'd like to give gertjan's script a try. Thank you for not hitting me with a brick here :D