Hauppauge PVR150 working (concept)
Posted: Tue Mar 15, 2011 2:08 am
I've spent quite a while trying to get my retired PVR-150 to work with Zoneminder. Many suggestions, but I couldn't get anything to work...until yesterday. I tried all variations of the source, using ffserver, using the video24 and video32 devices, etc. In the end, there are a few ways to make it work, but here's what I ended up with. In a nutshell, you create an updated jpeg for ZM to poll (file source).
This is a workaround, for sure, but the performance is adequate for what I'm looking for. I'm running this on an Ubuntu 10.10 LAMP server on an Athlon 1 GHz box. My PVR150 is the type that runs with ivtv drivers. I can probably list some code later for those that are interested, but here's the higher level view of what I did to get it to work:
1. Get your card working to the point that you can cat the /dev/video0 source to a file, and play the resulting mpeg in your player. e.g. $ sudo cat /dev/video0 > /tmp/file.mpg creates a file you can view in mplayer or Windows Media Player. You will need to use v4l2-ctl to set the input. I used "1" for S-Video. My camera is an old Sony Video8 Handycam (has NightShot), using the composite out going to the PVR150 S-video in.
2. Start a process that copies /dev/video0 to a named pipe.
3. Start ffmpeg to read from the pipe, and transcode the mpeg stream to a series of jpegs at a reasonable framerate, like 5. I used a size of 320x240. You could just read from the /dev/video0 device, but using the pipe let's you "tee" it (I'll explain why I chose this later in this post).
4. Run another process to look for the most recent jpeg created in the folder, and move it to a consistent filename, that same process deletes the older series of jpegs. Use pattern matching to simplify this.
5. Define your Monitor in ZM to use a file source, pointed to your jpeg's consistent filename in step 4. I used a framerate of 2, with an alarm of 5. Make sure to use the *same* size settings as what was created in step 3. I used 320x240, 24 bit color. If you use different size settings, you'll get a black screen.
If all is well, ZM will pull the current JPG from the file. The one process keeps creating more jpegs, and the other keeps the "consistent" one updated. You'll see the result on your monitor.
In my setup, I also wanted to take advantage of the fullsize, 30fps mpeg video output from the card. FFMPEG can't generate 30 fps of jpegs on an Athlon 1GHz using this method, but you can tee the pipe to have the mpeg stream both copy to the pipe, and write to an mpeg file. I then have the mpeg file switch every hour to keep the filesize reasonable, so that an hour's worth is about 1.5 GB (my bitrate is something like 3000 kbs and the native size is 720x576). When the whole shebang is running, it's using about 40% CPU on my 1 GHz Athlon.
I can use ZM to find events and peruse them, but if I want nicer, large frame, smooth video to inspect, I can also go find it in the mpeg files that were created. My camcorder has a date/time stamp so it helps finding your item of interest fairly easy.
Hopefully this helps some of you find new life with these older mpeg encoder cards. I'll take any comments that might simplify this.
Robert
This is a workaround, for sure, but the performance is adequate for what I'm looking for. I'm running this on an Ubuntu 10.10 LAMP server on an Athlon 1 GHz box. My PVR150 is the type that runs with ivtv drivers. I can probably list some code later for those that are interested, but here's the higher level view of what I did to get it to work:
1. Get your card working to the point that you can cat the /dev/video0 source to a file, and play the resulting mpeg in your player. e.g. $ sudo cat /dev/video0 > /tmp/file.mpg creates a file you can view in mplayer or Windows Media Player. You will need to use v4l2-ctl to set the input. I used "1" for S-Video. My camera is an old Sony Video8 Handycam (has NightShot), using the composite out going to the PVR150 S-video in.
2. Start a process that copies /dev/video0 to a named pipe.
3. Start ffmpeg to read from the pipe, and transcode the mpeg stream to a series of jpegs at a reasonable framerate, like 5. I used a size of 320x240. You could just read from the /dev/video0 device, but using the pipe let's you "tee" it (I'll explain why I chose this later in this post).
4. Run another process to look for the most recent jpeg created in the folder, and move it to a consistent filename, that same process deletes the older series of jpegs. Use pattern matching to simplify this.
5. Define your Monitor in ZM to use a file source, pointed to your jpeg's consistent filename in step 4. I used a framerate of 2, with an alarm of 5. Make sure to use the *same* size settings as what was created in step 3. I used 320x240, 24 bit color. If you use different size settings, you'll get a black screen.
If all is well, ZM will pull the current JPG from the file. The one process keeps creating more jpegs, and the other keeps the "consistent" one updated. You'll see the result on your monitor.
In my setup, I also wanted to take advantage of the fullsize, 30fps mpeg video output from the card. FFMPEG can't generate 30 fps of jpegs on an Athlon 1GHz using this method, but you can tee the pipe to have the mpeg stream both copy to the pipe, and write to an mpeg file. I then have the mpeg file switch every hour to keep the filesize reasonable, so that an hour's worth is about 1.5 GB (my bitrate is something like 3000 kbs and the native size is 720x576). When the whole shebang is running, it's using about 40% CPU on my 1 GHz Athlon.
I can use ZM to find events and peruse them, but if I want nicer, large frame, smooth video to inspect, I can also go find it in the mpeg files that were created. My camcorder has a date/time stamp so it helps finding your item of interest fairly easy.
Hopefully this helps some of you find new life with these older mpeg encoder cards. I'll take any comments that might simplify this.
Robert