LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-29-2010, 01:03 AM   #1
masmddr
Member
 
Registered: Jun 2005
Location: Israel
Distribution: Arch Linux
Posts: 92

Rep: Reputation: 16
How to schedule a recording from a web cam?


Hello all.
I was wondering if any one could suggest of a way to schedule a recording from a webcam on a local machine.
for example I want my webcam to start recording video at say 7am and stop at 8am.

The webcam is working and all is set properly, I have wxcam which has a feature to record but I found nothing about scheduling for auto start and auto stop.
I was thinking using 'at' but I found nothing about command line for wxcam.
 
Old 08-29-2010, 03:39 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
All you really need is an appropriate cli command and a scheduler.

You can use mencoder, for example.

First, make sure mplayer can access your camera correctly:
Code:
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
You may have to adjust the settings to match your setup. Also, the above is video only.

Once you know it's working, you can set up a recording command:
Code:
mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:forceaudio:adevice=/dev/dsp1 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o ~/webcam.avi
Again, alter the settings as you see fit. As you can see, this one includes audio. I just grabbed these commands off the net somewhere a while back, so they probably aren't optimal.

Then you can wrap it in a simple script and use timeout to stop the recording after a set length of time. (mencoder also certainly has a built-in recording time option somewhere, but I don't feel like digging through the man page to find it.)
Code:
!#/bin/bash

timeout 60m mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:forceaudio:adevice=/dev/dsp1 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o ~/webcam.avi

exit 0
Finally, simply use cron or another command scheduler to run the script when you want it to. I'll leave this last part up to you to figure out.

Last edited by David the H.; 08-29-2010 at 03:42 AM. Reason: minor addition
 
1 members found this post helpful.
Old 08-29-2010, 04:00 AM   #3
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
This isn't really helpful.

But wow, I was just looking at some of my plants thinking "How cool would it be to have my web-cam take a photo at the same time every day and then render it into a video.

Now I think I have the tools to go ahead (I don't need timeout, but thats an interesting one which I'd never heard of)
 
Old 08-29-2010, 04:07 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Well, there's more than one way to skin a cat...err, to schedule a recording. I just posted the first one that came to my head. A bit of searching should turn up more.
 
Old 08-29-2010, 07:58 AM   #5
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
Quote:
Originally Posted by djsmiley2k View Post
This isn't really helpful.
Wait wait wait.

I meant my post isn't really helpful! hahaha. I like what you've written, it looks good and I want to use it.
 
Old 08-29-2010, 09:14 AM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Not to worry. I figured out what you really meant, although it did throw me for a moment. I was mostly responding to the second part of your post.
 
Old 09-04-2010, 02:45 AM   #7
masmddr
Member
 
Registered: Jun 2005
Location: Israel
Distribution: Arch Linux
Posts: 92

Original Poster
Rep: Reputation: 16
Thank you for the replays and sorry it toke me so long to respond.
I seem to be having a problem with something.
WxCam works fine when set to v4l2.

output for
Quote:
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
Code:
mas:$ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
MPlayer 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU     T7250  @ 2.00GHz (Family: 6, Model: 15, Stepping: 13)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
Selected device: PC Camera
 Capabilites:  video capture  read/write  streaming
 supported norms:
 inputs: 0 = zc3xx;
 Current input: 0
 Current format: unknown (0x4745504a)
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl set Brightness 128 failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
FPS not specified in the header or invalid, use the -fps option.
No stream found.

v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.

Exiting... (End of file)
using 'driver=v4l ' opens mplayer and shows this:
http://img28.imageshack.us/img28/702...hotmplayer.png

and
Code:
Audio: no sound
Starting playback...

ioctl mcapture failed: Invalid argument

ioctl mcapture failed: Invalid argument

ioctl mcapture failed: Invalid argument
V:   0.2   7/  7 ??% ??% ??,?% 0 0 
ioctl mcapture failed: Invalid argument
V:   0.3   8/  8 ??% ??% ??,?% 0 0 
ioctl mcapture failed: Invalid argument

ioctl mcapture failed: Invalid argument
V:   0.6  15/ 15  0%  6%  0.0% 0 0 
ioctl mcapture failed: Invalid argument
V:   0.6  16/ 16  0%  6%  0.0% 0 0 
ioctl mcapture failed: Invalid argument
the part with mencoder is the same, so is with vlc.


got me libv4l-0.5.97 from slackbuilds.org and nothing changed.
 
Old 09-04-2010, 08:43 AM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Like I said, I just pulled the command off the web, so I can't comment on whether it's appropriate for you as-is. It works just fine with my LogiCool webcam.

I do get most of the same "errors" that you do, except for this one.
Code:
FPS not specified in the header or invalid, use the -fps option.
No stream found.
Perhaps your cam doesn't present the right framerate information to the system or something. Try adding something like -fps 30 to the command, like it suggests. Try changing the frame size values too.

Incidentally, for some reason vlc fails to open my device when I use v4l2, but it works just fine if I specify it as v4l. Strange.
 
Old 09-04-2010, 11:54 AM   #9
masmddr
Member
 
Registered: Jun 2005
Location: Israel
Distribution: Arch Linux
Posts: 92

Original Poster
Rep: Reputation: 16
you were right, -fps did the trick.
mencoder and vlc are still no go but

Quote:
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 15 -vo jpeg
outputs the video from the webcam to jpeg files, I just need to find the right thing to replace 'jpeg' with, avi and mpeg don't work.

Quote:
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl set Brightness 128 failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
Error opening/initializing the selected video_out (-vo) device.

v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.

Exiting... (End of file)
all I need to do now is find the correct replacement or just set a slide show at 15fps

thank you.
 
Old 09-05-2010, 06:11 AM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I'm not very experienced with mplayer, as I usually use ffmpeg for my media work. But it's my understanding that mplayer is mostly only capable of saving simple stream dumps and the like, and that you really need to use mencoder for more advanced transformations. mplayer -vo help doesn't show me any output types that would be useful for advanced video. But the same -fps 15 should work with mencoder as well.

As I see it, the basic mencoder syntax isn't all that difficult. You specify the video and audio codecs you want to use with -ovc and -oac, then depending on what you've entered, you also add secondary options to control the various codec parameters. Here are a couple of pages that seem to cover the basics well:

http://en.gentoo-wiki.com/wiki/Mencoder
http://www.linux.com/archive/articles/121385

By the way, I've also discovered the option that allows you to control the length of recording. Add -endpos 1:00 to record one hour of video.

Last edited by David the H.; 09-05-2010 at 06:14 AM.
 
Old 09-05-2010, 07:11 AM   #11
masmddr
Member
 
Registered: Jun 2005
Location: Israel
Distribution: Arch Linux
Posts: 92

Original Poster
Rep: Reputation: 16
Quote:
mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ovc lavc -o ~/webcam.avi
gives
Quote:
MEncoder 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU T7250 @ 2.00GHz (Family: 6, Model: 15, Stepping: 13)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 9 data: 0x0 - 0x0
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
comment: first try, more to come ;-)
Selected device: PC Camera
Capabilites: video capture read/write streaming
supported norms:
inputs: 0 = zc3xx;
Current input: 0
Current format: unknown (0x4745504a)
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Invalid argument
Error: Cannot set norm!
Selected input hasn't got a tuner!
Audio block size too low, setting to 16384!
Floating point exception
so I'm thinking of just giving up or just use mplayer with jpeg.
Thank you for your help.
 
Old 09-05-2010, 07:41 AM   #12
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Well, for one thing, you still haven't added -fps to the command. mencoder will certainly need the same input options that mplayer uses. They're just the playing and encoding modules of the same program after all.

I don't see why you should give up so easily. Now that you know for sure that mplayer works, all you need to do is find the proper parameters to use. The links I provided in my last post should be enough for you to figure it out.
 
Old 09-05-2010, 09:21 AM   #13
masmddr
Member
 
Registered: Jun 2005
Location: Israel
Distribution: Arch Linux
Posts: 92

Original Poster
Rep: Reputation: 16
Right I forgot the -fps part but it doesn't make mencoder work so it must be something else.
I'll read the links in depth when I have the chance.
again thank you for your help.
 
Old 09-05-2010, 10:05 PM   #14
mecelec415
Member
 
Registered: Jan 2008
Location: Noble Park ,Victoria, Australia
Distribution: Mageia
Posts: 183
Blog Entries: 2

Rep: Reputation: 23
http://www.pierrox.net/dvr/
digital video recorder is easy seams to work ok the few times I ve used it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
would like to play aMSN web cam sessions (.cam extension) using external program Gogul Linux - Software 5 09-17-2006 08:51 AM
web based flight schedule software kapilcool Linux - Software 1 06-06-2006 11:17 AM
Web Cam Hophoto SUSE / openSUSE 1 02-21-2006 10:18 PM
web cam and web cam server citrus Linux - General 2 03-24-2004 09:28 PM
is there a good web cam recording program matt_w_lambert Linux - Software 1 06-04-2003 06:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration