Page 1 of 1

Viewing nph-zms output directly?

Posted: Tue Nov 09, 2010 5:24 am
by jdhar
Does anyone know if there is a way to view the MJPEG stream generated by nph-zms directly? I know if you embed it in an <img>, like the watch.php screen does, you can view it through the web... but what I would like to do is take the output of nph-zms and pipe it to FFMPEG locally. Is this possible through the command line interface to nph-zms?

Posted: Tue Nov 09, 2010 9:44 am
by Pada
Well, you can try specifying '-f mjpeg' just before the input. eg.

Code: Select all

nph-zms | ffmpeg -f mjpeg -i - -f asf -sameq -o video.asf
* I can't verify this at this moment, since I'm at work.

I'm not sure if you can redirect nph-zms' output to STDOUT though, which is why I've modified zms.cpp to take command-line arguments and output to STDOUT. You can download my source code here: http://www.mediafire.com/?i6dvgn690e1sknk
To compile it you would require all the ZM source code.

Is there any particular reason why you want to use MJPEG and not MPEG?
What exactly do you want to do with FFMPEG?

The reasons I'm asking this is because I've recently done a project on ZoneMinder and its streaming.

Posted: Tue Nov 09, 2010 5:01 pm
by jdhar
Thanks Pada. Redirecting nph-zms to STDOUT is the big question, and like you said, I don't think i can take command line args since it's meant to get them from the ENV variables when called as a cgi-bin app.

Using MPEG or MJPEG actually doesn't matter, but I'm trying to do a test to stream nph-zms using H264 w/ FFMPEG. Is this similar to what you have done? What version of ZM did you modify the zms.cpp file from?

Posted: Tue Nov 09, 2010 8:27 pm
by jdhar
Pada, I adapted your source and it's working great. Good work :)

Posted: Wed Nov 10, 2010 7:36 pm
by Pada
OK, great. I'm glad my ZoneMinder project that I did for my final year project at the University had some use :)

I take it that you've solved all your issues, seeing as you gave good feedback in my Ubuntu 10.10 install script thread: http://www.zoneminder.com/forums/viewto ... 5723#65723

I would still love to test the Matroska (.mkv) Event Storage + Axis RTSP/H264 fixes user contribution that warmcat made.

I've tried to stream with zms using the x264 codec, but I was not able to. Using FFmpeg to stream in x264 is easy, but I wasn't able to use the FFmpeg library to do that.
One of the issues was that FFmpeg has presets for x264, but there are no libraries available to simply import those presets, which is why I took the time to look for all the variables associated with the preset names.
I posted my results here: http://stackoverflow.com/questions/3553 ... codec-x264

Posted: Wed Nov 10, 2010 7:40 pm
by jdhar
Getting your zmstreamer to output H264 natively by using the ffmpeg lib would be a great addition. Like you said, I now have zmstreamer --> ffmpeg --> segmenter working well, but there is some startup delay in invoking a large pipe.

Once I have this incorporated into eyeZm, I'll see if I can contribute to condensing the above pipe into zmstreamer.

Posted: Wed Nov 10, 2010 8:01 pm
by Pada
OK. I agree with you that native x264 support in ZMS would be awesome. Perhaps with the help of warmcat we might be able to do that.

Off topic: do you also have trouble with the Apple Store, where the applications would take forever to be authorized/accepted?

Here's a timeline of how I came about changing ZMS :):
In my project I first started with xlib_shm and I've then tried to stream the videos instead of simply playing it on the desktop, but that did not work out since I got absolutely no support from the FFmpeg community (both IRC & mailing list failed badly).

I've then added mmap support for xlib_shm, because it was simply annoying to install ZM with shared memory (--disable-mmap) just to be able to use xlib_shm.

Since ZMS was already working quite nicely, but it took ENV variables & piped to Apache CGI like you've said. I've then basically copied the command-line stuff from xlib_shm into my ZMS and redirected the debugging info to STDOUT too.
I've done basically all my tests by piping my modified ZMS to VLC. I've also used Mplayer/FFmpeg every now and then.

You can also stream (and transcode) with cvlc (command-line VLC), but then you're restricted to 1 video stream per network port AFAIK.
Eventually I came to the conclusion that using ZMS to stream via Apache is still one of the best options available, except that Apache/ZMS will often just crash for a reason still unknown to me.