2in1 - AMC as mjpeg player in IE and zms as stream proxy

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
W.
Posts: 108
Joined: Tue Apr 10, 2007 5:06 pm
Location: Latvia

2in1 - AMC as mjpeg player in IE and zms as stream proxy

Post by W. »

Hi

Well, subject almost says it all. 2 features in one patch (I'm just too lazy to split those two up):

1) IE is known not to play mjpeg streams natively. cambozola.jar is used in original ZM distro, but this neat java app is lagging behind the actual image from camera. Something more native was needed to play mjpegs in IE. As I am interested almost only in Axis cameras I went for Axis Media Control redstributable cab that can be found at http://www.axis.com/techsup/cam_servers/dev/activex.htm. Just download SDK, install and look for AMC.cab in Redist folder. Copy it to ZM html root or any other location you like, configure ZM_PATH_AMC in zm->options->images, check ZM_OPT_AMC at the very same location and off you go.
This is "AMC as mjpeg player in IE" part of patch.

2) Mjpeg streaming clogs up servers processor quite a bit even if using simd optimized jpeglib. Idea is to stream as directly as possible form camera, so that no recompression needs to be done on the server. The patch turns zms in mjpeg stream proxy if instructed so by options in Monitor setup. Three new config fields are added to the Source tab of monitor configuration for Remote cameras - "Axis Direct Stream", "Path template for direct streaming" and "Supported Resolutions". First just enables or disables the feature for given camera. Second field is used as template for building image request path, it has two placeholders, one for resolution - "%1$s" and second for fps - "%2$d". Third field contains list of supported resolutions and their respective pixel counts. This field can not be edited directly because of specific format requirements, so there is Edit button and special form that helps with that. In the resolution list edit form column Resolution contains string as it should be placed in request path (the template mentioned earlier) and passed to the camera, column pixels contains total pixel count for given resolution. Pixel count is used to calculate what resolution should be requested from camera. The resolution list should be in ascending order, ie smallest resolution goes first. For an example choose some Axis IP camera preset. And again, as I am interested mostly in Axis cameras, all the stuff has Axis name in it :)
This is "zms as stream proxy" part of patch. I know that actual code of proxy is not exactly where it should be, but that is no problem of mine at the moment ;) Btw, this might work for almost any mjpeg outputting camera.

Before you try and download, disclaimer, there is no warranty that this stuff will or will not work for you. I can not be held liable for anything related to ZoneMinder and this patch in particular. As soon as you download the patch you are on your own. And of course, YMMV.

http://inoperative/nv1.patch.gz
This is temporary location, therefore I do not know for how long the file will be there. OTOH, there is nothing more permanent than temporary, so it might stay there forever ;)

Patch was made possible in collaboration with company New Vision

Almost forgot - this is for zm 1.22.3

New download location:
http://www.o6.lv/files/nv1.patch.gz
Last edited by W. on Mon Apr 30, 2007 6:11 am, edited 1 time in total.
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Thanks for this, I was going to look into doing a stream proxy. This looks very good and well thought out and put together. 8)
Not to mention a great first post :D

Cheers,
Corey
W.
Posts: 108
Joined: Tue Apr 10, 2007 5:06 pm
Location: Latvia

Post by W. »

well, hello from 7 timezones away ;)
i hope someone will find this useful and it would be nice if somebody could test this with other ip cams.
and i hope there is more to come from me. at least latvian translation, if not some Axis related PTZ stuff and external triggering.
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Hi,

Belated thanks for this. I will try and merge this into the main stream source if I can do it without breaking anything else.

Cheers
Phil
W.
Posts: 108
Joined: Tue Apr 10, 2007 5:06 pm
Location: Latvia

Post by W. »

a couple of things to consider if you want to merge that in mainstream:
a) move proxy code from zm_monitor.cpp to zm_remotecamera.cpp, should not be that hard;
b) recheck socket read closing in proxy code, according to *nix socket faq, if read returns 0, remote end closed connection, but somehow i have feeling that with ip cameras it can sometimes not be true, for example if you get fractional frame rates;
c) length of resolution field that is passed to camera in url. it can be much longer on other brands of cameras, for example on iqeye it was something like ww=1600&wh=1200&ds=3

i am not coder, so that stuff can be and most likely is ugly :)
if common sense is so uncommon, why is it called common then?
Post Reply