Difference between revisions of "Zmodopipe"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 36: Line 36:


Connecting to ZM with the recommended "Source: ffmpeg" settings provided in the forum post did not work for me reliably. I saw it work once, among dozens of attempts. It was 6 fps (very good). It may be that older ZM worked better with zmodopipe than it does now.
Connecting to ZM with the recommended "Source: ffmpeg" settings provided in the forum post did not work for me reliably. I saw it work once, among dozens of attempts. It was 6 fps (very good). It may be that older ZM worked better with zmodopipe than it does now.




Line 82: Line 84:


=== ffserver and ffmpeg configurations for rtsp stream ===
=== ffserver and ffmpeg configurations for rtsp stream ===
<code>$ ./zmodopipe -s 192.168.1.100 -p 18004 -c 1 -v -u admin -a 123456  -m 1
$ ffserver -f /etc/ffserver4.conf
$ ffmpeg -f h264 -i /tmp/zmodo0 http://localhost:8090/feed1.ffm
$ cat /etc/ffserver4.conf
Port 8090
#RTSPPort 8554
#HTTPPort 8554
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
#MaxBandwidth 9000K
CustomLog -
NoDaemon
##################################################################
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 200K
ACL allow 127.0.0.1
</Feed>
##################################################################
<Stream test.mjpg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 10
VideoSize 320x240
VideoBufferSize 40
VideoGopSize 12
AVOptionVideo flags +global_header
NoAudio
</Stream>
<stream stat.html>
Format status
</stream>
Zoneminder settings:
Source: Remote
Remote Protocol: HTTP
Remote Method: Simple
Remote Host Name: localhost
Remote Host Port: 8090
Remote Host Path: test.mjpg
Target colorspace: 24 bit
Capture Width (pixels): 320
Capture Height (pixels): 240
Gets 2.5fps about.
</code>

Revision as of 22:29, 26 November 2016

Zmodopipe is a tool that can take the stream from certain model of DVRs and provide that stream through a Named Pipe where programs, including Zoneminder (through zm_ffmpeg_camera.cpp) and ffmpeg can read that stream.

User Case

I purchased a Night Owl Poseidon DVR in the hopes of getting zmodopipe to work with it. This is what I found.

Equipment: Ubuntu 14.04, Zoneminder 1.30, Night Owl Poseidon DVR8, Zmodopipe .41, ffmpeg 3.0 compiled from source (used current ffmpeg ppa for libraries)

Setup

Follow forum guide steps. Download and compile.

There are various quirks not mentioned in the thread which serves as its documentation. A lot of people have been confused.

Running Dots: When you have zmodopipe running in verbose mode (-v flag) and connect sucessfully to the DVR you will see a stream of dots. This means the pipe is created and ready for a reader. At this point zmodopipe will be using 0% CPU and 0% Memory. This is normal for named pipes at this point.

Dots stopping: When you connect a reader (Zoneminder or ffmpeg) to the pipe, the dots will stop. Again, this is normal behavior. You should see some CPU usage on the program accessing the pipe.


A typical zmodopipe for the night owl can be: ./zmodopipe -s <ipaddressofdvr> -p 18004 -v -c 1 -u <admin> -a <pass> -m 1

./zmodopipe -h

will tell you the flags, as any good CLI program should.

You will need to make sure the password is set in the DVR. By default, there may not be a password. The night owl required a 6 character password (exactly 6 characters). The night owl is able to be factory reset.

After you run the zmodopipe command with verbose mode enabled, you will see the dots moving. Now it's time to read from the pipe.


Connecting to Zoneminder

Connecting to ZM with the recommended "Source: ffmpeg" settings provided in the forum post did not work for me reliably. I saw it work once, among dozens of attempts. It was 6 fps (very good). It may be that older ZM worked better with zmodopipe than it does now.



What Worked

Using cat to create a video from the pipe.

$ cat /tmp/zmodo0 > capture.mp4

Did work. VLC or mplayer was able to watch the video. But that makes a single encoded video. While useful, its not sufficient for my needs.


Using ffmpeg to read from the pipe and send it somewhere DID work. I was able to:

$ ffmpeg -f h264 -i /tmp/zmodo0 capture.mp4

$ ffmpeg -y -f h264 -i /tmp/zmodo0 -update 1 -vf fps=5 /tmp/image.jpg

The first option is the same result as cat, HOWEVER the second option creates an updating jpg. Zoneminder is able to read from the latter using Source:file getting roughly 1.2 fps. At times I would receive invalid data read from the stream, though, and this would mean that the latter option does not work 100% of the time.


Using ffmpeg AND ffserver together. ffmpeg reads from the pipe, and sends the output to ffserver who serves it as an rtsp stream to ZM.

This gets more complex. Ffserver is a great program or was, until they decided to discontinue it. I won't explain ffserver here, but simply put, ffmpeg is unable to run a server of its own, so ffserver fills that role. You must use ffserver with ffmpeg in order to restream media.

Beware: ffserver must be <3.1 in order to stream rtsp without a segfault. I was able to get ffserver running with ubuntu 14.04 and ffmpeg 3.0 compiled.


ffserver has some issues with its sample configuration and complaining about a missing audio stream. The solution is to take a working config from someone in the ffserver forum who was able to go without audio. There are some examples there.


Workflow:

  • Run zmodotool
  • Run ffserver
  • Run ffmpeg
  • Zoneminder can connect to the rtsp stream


Here are some useful configurations for this setup. I was able to get about 2.5 fps with this setup.

ffserver and ffmpeg configurations for rtsp stream

$ ./zmodopipe -s 192.168.1.100 -p 18004 -c 1 -v -u admin -a 123456 -m 1

$ ffserver -f /etc/ffserver4.conf

$ ffmpeg -f h264 -i /tmp/zmodo0 http://localhost:8090/feed1.ffm


$ cat /etc/ffserver4.conf

Port 8090

  1. RTSPPort 8554
  2. HTTPPort 8554

BindAddress 0.0.0.0

MaxHTTPConnections 2000

MaxClients 1000

  1. MaxBandwidth 9000K

CustomLog -


NoDaemon



<Feed feed1.ffm>

File /tmp/feed1.ffm FileMaxSize 200K

ACL allow 127.0.0.1

</Feed>

<Stream test.mjpg> Feed feed1.ffm Format mpjpeg VideoFrameRate 10 VideoSize 320x240 VideoBufferSize 40 VideoGopSize 12 AVOptionVideo flags +global_header NoAudio </Stream>

<stream stat.html> Format status </stream>






Zoneminder settings:

Source: Remote Remote Protocol: HTTP Remote Method: Simple Remote Host Name: localhost Remote Host Port: 8090 Remote Host Path: test.mjpg Target colorspace: 24 bit Capture Width (pixels): 320 Capture Height (pixels): 240


Gets 2.5fps about.