Zmodopipe

From ZoneMinder Wiki
Jump to navigationJump to search

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. The below is my experience with one particular DVR. Overall, I found that dedicated Video Encoders were better, though for some niche applications, Zmodopipe may be considered.

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

Adding the -h flag will tell you the options, 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). You will also find this password limitation on many IP Cameras (microcontrollers have limited memory). 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 useful, but possibly not easy. 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: At the time this was written (14.04 LTS Ubuntu Repos) ffserver must be <3.1 in order to stream rtsp without a segfault (Note: link dead due to FFServer forum being removed). 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, but since the forum is no more, I've copied one below.


Workflow:

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

Note: The -f h264 is NOT required. However, it speeds up identification of the source stream by ffmpeg, and is recommended.

Note: I was only able to get zmodopipe and the Night Owl to work in -m 1, and I think -m 5 (same resolution as 1). I was not able to get a higher resolution than 320x240. I was able to 'stop the dots' on -m 2, but was unable to get ZM to read from it.

Note: Running ffmpeg jpg output and the ffmpeg restream at the same time may eat into eachothers fps.

ffserver and ffmpeg configurations for rtsp stream

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


$ ./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.


Conclusion

Zmodopipe is not worth it with the Night Owl Poseidon. It may work better with other DVR models, or older ZM versions. Overall, you are better off getting an external network encoder, or a bttv card.

Ispyconnect has a number of h264 and jpeg paths for DVRs. Look into that. Not all of them will work, but some might.

I think there's one DVR mentioned in the zmodopipe forum post that offers a stream on rtsp://<ip>:554, without need for zmodopipe. Resolution is likely lower than 640x480. There are probably others, but you'll have to dig through user manuals.

It may be possible to stream using VLC. I didn't investigate.

FFserver is neat, and worth a look.

External Links