Hi stevieb, I played around with it awhile back and found a couple of problems which you maybe able to overcome. First with v4l2 I was only able to grab single pictures at a time, however, they could easily be assembled into a video. Second, I could not find an efficient way to display the video in reatime, and save it simultaneously. My advice would be to use mplayer or mencoder, which can be run in slave mode for scripting.

I have a raspberry pi too, and I love it. If I were attempting it, I would use either mplayer or mencoder run by perl in slave mode, which you can see a sample of in ztk-v4l-video-bloger/recorder. That link shows the use of slave mode, but the v4l part is outdated. It may help you though. Basically you get a window id of the Tk container, the canvas is easiest, and pass that window id to mplayer in slave mode.

I have 2 working mplayer snippets which you may find useful. First is just display the camera in realtime.

mplayer -tv device=/dev/video0:fps=29.97 tv://
The following nicely records video and audio
mencoder \ + tv:// \ + -tv driver=v4l2:device=/dev/video0:fps=30:width=640:height=480:for +ceaudio:alsa:adevice=hw.0,0 \ -ovc lavc \ + -oac lavc \ + -ffourcc divx \ + -noskip -mc 0 -ofps 30 \ + -o record-compressed-good-sync.avi

The problem is to get them to work simultaneously, so you can have a realtime Tk display and save to a file as you go. The mplayer and mencoder options show a -dumpstream and -dumpfile option, but I as yet have gotten them to work together. Some have suggested using a tee for output, but no luck there either. Maybe you will be the one to discover the coding trick needed.:-). So, I recommend using a c program to do the heavy video work, rather than Perl.

Here is an informative link describing the problem in full. play record same time.


I'm not really a human, but I play one on earth. ..... an animated JAPH

In reply to Re: Perl wrapper for v4l2-ctl by zentara
in thread Perl wrapper for v4l2-ctl by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.