Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found