[FEATURE] DeInterlace your BTTV cam

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
pki
Posts: 29
Joined: Sat Mar 06, 2010 8:59 am

[FEATURE] DeInterlace your BTTV cam

Post by pki »

Hi there.

Preliminary i have solved the interlacing issue for me. Of course an small increase of the CPU load is happened. The mencoder takes about 2% of a dualcore@2.93GHz for a 768x576x24 source at 4fps.

I used:
- zm 1.24.2 from svn
- ubuntu server 9.10 x64
- mencoder
- avld 0.1.4 with patch for newer kernel (another video loopback device)
- bttv cards
The solution is not difficult. After compiling and installing avld lod the module with

Code: Select all

sudo modprobe avld width=768 height=576 fps=0 palette=0
A new /dev/video* will be created. For me it is video10. Now capture the video source video0 with mplayer, deinterlace it, convert to rgb24* and send to the loopback device of video10.

Code: Select all

mencoder tv:// -tv driver=v4l2:width=768:height=576:device=/dev/video0:noaudio:norm=PAL:outfmt=yv12:fps=3 -nosound -ovc raw -vf yadif,scale,format=bgr24 -of rawvideo -o /dev/video10
The source of the video in zoneminder is set to:
- Video for Linux 1
- RGB24
- 768x576
- PAL

Of course there is a daemon to write, it should monitor the loading process of the devices, run and restart if necessary the mencoder.

Links:
AVLD 0.1.4 http://allonlinux.free.fr/Projets/AVLD/
Patch from http://ubuntuforums.org/showthread.php?t=1386972
Other AVLD patch (not used) http://wiki.elphel.com/index.php?title= ... ack_Device


Please please please, who is interested in this should try it, i am VERY INTERESTED in FEEDBACK from YOU. Feel free to drop a line here or at my email.
SQ2LYH :-)
TT_ZX
Posts: 9
Joined: Thu Mar 11, 2010 7:24 am

Post by TT_ZX »

Works great but can AVLD spawn more than 1 loopback device?
pki
Posts: 29
Joined: Sat Mar 06, 2010 8:59 am

Post by pki »

No, at this time you can load it only once. I will work on it and try to solve the problem.
SQ2LYH :-)
50cc
Posts: 82
Joined: Sun Mar 23, 2008 12:01 pm
Location: The Netherlands

Post by 50cc »

Cool! :)

As we talked about I did basically the same last year, good job for documenting it! :)

If I find some time I will also start messing around with this feature.....
TT_ZX
Posts: 9
Joined: Thu Mar 11, 2010 7:24 am

Post by TT_ZX »

Have you tried using V4L2 Virtual Device. Looks like it will work and supports multiple pipes. I'm having a bit of trouble getting it work.
http://sourceforge.net/projects/v4l2vd/
pki
Posts: 29
Joined: Sat Mar 06, 2010 8:59 am

Post by pki »

Does not compile here at the x64 machine.
SQ2LYH :-)
TT_ZX
Posts: 9
Joined: Thu Mar 11, 2010 7:24 am

Post by TT_ZX »

Compiles fine on 32bit. Did you download from CVS?
User avatar
kongobongo
Posts: 15
Joined: Fri Apr 09, 2010 5:09 pm

Post by kongobongo »

Did you manage to make any progess on getting more than one instance to run?

I have two BT cards in my ZM box and would love to get them both de-interlacing!
TT_ZX
Posts: 9
Joined: Thu Mar 11, 2010 7:24 am

Post by TT_ZX »

Not me. I was hoping pki could work something out.
wk2
Posts: 2
Joined: Sun Apr 11, 2010 5:15 am

Post by wk2 »

Hi PKI,

Thank you for your tipps. Your solution with AVLD and mencoder works great for me (run via rc.local). The "kerndeint" algorithm instead of the "yadif", however, saves a lot CPU time and yields good results also.

I would like to deinterlace the input of 3 cameras and looked at the video 4 linux virtual device approach:

I am running a 64bit architecture based on ubuntu 10.04LTS (kernel 2.6.32). The V4l virtual device can be compiled without problems:
1. Download regular version from sourceforge page
2. Replace v4l2vc.c and v4l2vc.h with newest versions directly from the CVS tree:
http://v4l2vd.cvs.sourceforge.net/viewvc/v4l2vd/
2. Open v4l2vd.c with an editor and add the following line in the beginning:
#include (linux/sched.h)
Please replace the brackets by <and>, I had to modify this as the board otherwise filtered the code!
3. Install g++ compiler/tools on your linux distribution
4. Now run "make" and "make install".

Now the virtual device can be loaded with modprobe as described in README (allowing multiple pipes).

Having gone this far, unfortunately I do not manage to send the mencoder output to the input device and get it looped to the output device. Mencoder seems to output to the V4lvd input device, but the stream is not passed to the output device. There are explanations in the NOTES file, how to set up a piped stream using the v4lvdsource command to suply the source via a fifo pipe. My first tries seemed to partially work, but after a view seconds, mencoder stops processing with the error message "video buffer full".

Does anyone know how to redirect the mencoder output to the v4lvd device?

Best regards!
Post Reply