Page 1 of 4 123 ... LastLast
Results 1 to 10 of 39

Thread: webcam & microphone command line fun ....

  1. #1
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,258
    Blog Entries
    34

    Default webcam & microphone command line fun ....

    A few unrelated events motivated me to start playing with my laptop's webcam today .... and have some fun

    First, because the maid was cleaning my computer room, and my wife was having a party with her Thai girl-friends, I was evicted for a short time from my computer room. ... Also, I did not go outside, as I am fighting off a mild feaver, so I decided to stay inside, and play with the family laptop (Dell Studio 15) , accessing the web via our home wireless.

    I also was trying to support user Larry1019 who wanted to get his internal mic working. I had long since stopped trying to get the internal mic working on my laptop, and when user Larry1019 asked for support, I was rather negative. This was my FAULT.

    So I was composing a reply to him, when I recalled I had read (and saved) an Ubuntu user's solution for the internal integrated laptop mic, but I was busy and I had discarded it because it got a bad Ubuntu reception from various Ubuntu newbies ..... So I decided to try the solution on my laptop, and well .... , one thing lead to another, and my internal mic was working because of that Ubuntu thread.

    So I then thought, since my laptop's integrated mic is working, lets see how far I can go with this, from the command line.

    Here are some interesting (for me) command line commands one can use to record audio and video from their webcam and mic. Note one needs the Packman packaged libffmpeg0, ffmpeg, and mplayer to use the commans below:

    To just play video (no recording):
    Code:
    mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
    To record both video only in the file "webcam.avi":
    Code:
    mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -ovc lavc -o webcam.avi
    To record both video and audio in the file "webcam.avi":
    Code:
    mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi
    or with ffmpeg, to record both video and audio in the file "out.mpg":
    Code:
    ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
    Note with ffmpeg, on my laptop, the audio was about 400 msec ahead of the video. This was easily fixed in avidemux. The mencoder command did not have the audio/video sync problem.

    My Dell Studio 15's webcam is an ID: 05ca:18a1 Ricoh Co., Ltd and it works with the uvc driver.

    I found the above commands on a Ubuntu thread, and I modified the commands very slightly to work on openSUSE. https://help.ubuntu.com/community/Webcam

    Maybe we can have some more fun on this thread. ... Does anyone else know of any neat COMMAND LINE commands to use to play with one's mic and webcam?

  2. #2
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,258
    Blog Entries
    34

    Default Re: webcam & microphone command line fun ....

    Quote Originally Posted by oldcpu View Post
    To record ... video only in the file "webcam.avi":
    Code:
    mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -ovc lavc -o webcam.avi
    Interesting. When I tried that on my very (very) old sandbox PC, with a Phillips webcam (uses the kernel module pwc) it did not work. I obtained the error:
    Code:
    oldcpu@stonehenge01:~> mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ovc lavc -o webcam.avi
    MPlayer dev-SVN-r29116-4.3-openSUSE Linux 11.1 (i686)-Packman (C) 2000-2009 MPlayer Teamsuccess: 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: Philips 740 webcam
     Capabilites:  video capture  read/write  streaming
     supported norms: 0 = webcam;
     inputs: 0 = usb;
     Current input: 0
     Current format: YUV420
    v4l2: ioctl set format failed: Invalid argument
    tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
    Selected input hasn't got a tuner!
    v4l2: Cannot get fps
    Audio block size too low, setting to 16384!
    Floating point exception
    So instead I tried this line:
    Code:
    mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ofps 60 -nosound -ovc lavc -lavcopts vcodec=mjpeg -o test.avi
    and that works !! I'm wondering, is it the video codec? ie. my desktop sandbox PC likes "mjpeg" but not "-ovc lavc" ...

  3. #3
    Join Date
    Jun 2008
    Location
    Kln, Deutschland
    Posts
    1,054

    Default Re: webcam & microphone command line fun ....

    Groovy oldcpu, it works perfectly on my HPdv6645 laptop

    It has a - ID 064e:a101 Suyin Corp. Acer CrystalEye Webcam built in.

    I've often tried to record from the webcam, but never had success.

    I'll keep a copy of those commands handy.

    Well done .

  4. #4
    Join Date
    Jun 2008
    Location
    Tallinn, Estonia
    Posts
    226

    Default Re: webcam & microphone command line fun ....

    Thank you!
    These command do allmost all, what I want.
    By the way, you can change 'mplayer' to other GUI,
    for example 'smplayer' (I find it a little bit better).

    The only thing I look for is some program
    or command to take photos, not only screenshots from the video.

    The reason for doing it is quite simple: photos have grater resolution.
    (Specifications say: "Integrated 2 MP camera (1600 x 1200 max resolution)".)
    Yes, I know, that quality won't be perfect, but sometimes quality doesn't really matter
    and it's easier to quickly take photos straight from the webcam to hard disk.

    I have tried about a dozen of different special web camera
    applications and none of them did everything, that the command you gave do.
    I found only one, which actually worked for me (luvcview),
    but it doesn't record any video, let alone recording video with sound,
    and saves pictures in some weird format, not png or jpg.
    (Maybe I can't get other programs to work
    because I have installed 64 bit system.
    Yes, it was to reckless for me to choose 64 bit...)

  5. #5
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,258
    Blog Entries
    34

    Default Re: webcam & microphone command line fun ....

    My desktop webcam (an old Phillips) is limited in its resolution. I don't know the top resolution of my Dell Studio 15's integated web cam (05ca:18a1 Rocoh) , but it may not be any better than 640x480.

    I can take a snapshot by streaming the video to the display:
    Code:
    mplayer -vf screenshot -fps 15 tv:// -tv  driver=v4l2:device=/dev/video0
    and then press "s" to take a snapshot, and press "q" to quit.
    That gave me 640x480 (presumeably a default resolution).

    I also played with:
    Code:
    mplayer tv:// driver=v4l2:width=800:height=600:device=/dev/video0 -fps 15 -vf snapshot
    and that gave me 800x600 video, and after I pressed 's' i obtained 800x600 in the snapshot.

    I did the same for 1024x768, 1280x1024, and 1600x1200 and obtained a 1024x768, 1280x1024, and 1600x1200 video and snapshot respectively.

    Note the webcam in my Dell Studio 15 laptop is not the most expensive integrated webcam on the block, so the resolutions larger than "640x480" may not be a "true" 800x600 or 1024x768, or 1280x1024 or 1600x1200 resolutions (ie I believe the images are dynamically sized up).

    But maybe with a more capable web cam, the image will be better.

    I can not test this without the hardware.

  6. #6
    Join Date
    Jul 2008
    Location
    Netherlands
    Posts
    1,133

    Default Re: webcam & microphone command line fun ....

    Haha great stuff,
    Render yourself in ASCII.
    mplayer -vo caca tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
    (libcaca required)

    http://www.imagebam.com/image/dcc11336802809
    (guess my t-shirt!)
    Special effects <- KDE 4.2 Showing off
    More KDE -> PINK KDE

  7. #7
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,258
    Blog Entries
    34

    Default Re: webcam & microphone command line fun ....

    Anyone else with some neat webcam command lines ?

  8. #8
    Join Date
    Mar 2008
    Location
    Europe
    Posts
    26,258
    Blog Entries
    34

    Default Re: webcam & microphone command line fun ....

    Quote Originally Posted by Axeia View Post
    Render yourself in ASCII.
    mplayer -vo caca tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
    (libcaca required)
    Neat ! Thx.

  9. #9
    Join Date
    Jun 2008
    Location
    Cluj, Romania
    Posts
    77

    Default Re: webcam & microphone command line fun ....

    Helpful post! Thank you very much.
    Respect the penguin!

  10. #10
    Join Date
    Jun 2008
    Location
    Wales, MA
    Posts
    486

    Default Re: webcam & microphone command line fun ....

    You need xwinwrap for this to work.

    Puts your webcam on your desktop as the background, yes icons and such still work

    Code:
    xwinwrap -ni -o 0.60 -fs -s -sp -st -b -nf -- mplayer -wid WID -quiet -fps 20 tv://

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •