Whiskey Kilo Linux  •  Exploring GNU/Linux and F/OSS
intrepid.jpg

Monday 6th February 2012

drupal member logo

drupal logo

ubuntu logo

gnome logo

opensource logo

Capture video from webcam with ffmpeg

Logitech Quickcam Vision Pro (Mac)I just bought a new webcam, a Logitech Quickcam Vision Pro (Mac version, 046d:09a6) with hardware controlled autofocus. Pictures are really sharp and the autofocus is cool too. Anyway, i needed to capture a small video with sound. Here's the ffmpeg command i used.
ffmpeg -t 10 -f video4linux2 -s 320x240 -r 30 -i /dev/video0 -f oss -i /dev/dsp1 -f mp4 webcam.mp4
No need to compile ffmpeg, this works out of the box!

Comments

Composite input

How do I tell ffmpeg to use the composite input of my TV tuner device in Linux. The primary device is /dev/video1. In a program like Tvtime I can toggle to the composite input. Any help would be greatly appreciated.

Use v4l2-ctl -i 2

I'm by no means an expert on ffmpeg, but maybe you can try v4l2-ctl -i 2 to switch to composite. I didn't try it myself, so best to also read man v4l2-ctl

mac

For a second there I thought you were using ffmpeg to record from a webcam in OS X. Anybody know if this is possible? You can do this in windows by using directshow input: http://betterlogic.com/roger/2011/08/ffmpeg-directshow/

capturing audio from webcam using ffmpeg on WinXP

The command here is only to capture video from webcam. Do you have any option that we can add with this command and make ffmpeg capture audio also from webcam?

From the ffmpeg man page:

From the ffmpeg man page: ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg

Not sure how this works on XP. I use linux exclusively.

Question!

I would also like some answers if it can be done with windows?

I'm trying to do in windows

I'm trying to do in windows XP with a Logitech Quickcam pro 9000, but it seem to be a problem with the vfwcap driver...this use the new WDM driver provided by Microsoft.
Anyone could help me??

To record sound on my Fedora

To record sound on my Fedora 14 system using alsa, I had to set the sound input to '-f alsa -i hw:0,0', or '-f alsa -i default'. For reasons of its own, ffmpeg does not accept the /dev/blah device designation for alsa audio, but does for oss audio and for video. Sigh.

script fail

I installed it. Ran the script. The light on my webcam went on momentarily then it died.

"[oss @ 0x953ff30]/dev/dsp1: No such file or directory"

[user@localhost ~]$ uname -r
2.6.34.7-56.fc13.i686

Full error below. All help appreciated.

ffmpeg.i686 0:0.6-3.fc13

Complete!
[user@localhost ~]$ ffmpeg -t 10 -f video4linux2 -s 320x240 -r 30 -i /dev/video0 -f oss -i /dev/dsp1 -f mp4 webcam.mp4
FFmpeg version 0.6-rpmfusion, Copyright (c) 2000-2010 the FFmpeg developers
built on Jul 27 2010 03:51:48 with gcc 4.4.4 20100630 (Red Hat 4.4.4-10)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-version=rpmfusion --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avfilter-lavf --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-runtime-cpudetect
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 0.11. 0 / 0.11. 0
libpostproc 51. 2. 0 / 51. 2. 0
[video4linux2 @ 0x953e860]Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
Duration: N/A, start: 34034.144617, bitrate: 36864 kb/s
Stream #0.0: Video: rawvideo, yuyv422, 320x240, 36864 kb/s, 30 tbr, 1000k tbn, 30 tbc
[oss @ 0x953ff30]/dev/dsp1: No such file or directory
/dev/dsp1: Input/output error
ioctl(VIDIOC_QBUF)

Name webcam sound device

Maybe /dev/dsp1 isn't the webcam sound device in your setup. Try the 'dmesg' command right after plugging in the webcam and see what the name of your webcam sound device is.

Thanks

That is really appreciated!!! And so simple :)

To preview couldn't you command ffmpeg to take .jpg frames from video and display in HTML with refresh ..or capture to flash video and simultaneously display with flash player.

can i do this in windows xp

can i do this in windows xp

Yes, You can do it in Windows.

Yes You can do it in Windows XP.
Right now I have did it.
the command is to be typed on command prompt.
go to cmd prompt. set path to the folder containing ffmpeg executable.
then type command as:
ffmpeg -r 25 -f vfwcap -i 0 output.avi

example:
c:\ffmpeg\bin>ffmpeg -r 25 -f vfwcap -i 0 output.avi

prior to the command shows the path of the folder containing the ffmpeg.exe

On running this command the web-cam attached to your system starts capturing the video. Its working fine.
Main problem in front of me now, is to show the preview of video being recording. So trying that out. Also I need to integrate ffmpeg to my existing MSVC++ project, which needs a lot of things to taken care.
So, guys I am doing it..

Hello Kamal, I would like to

Hello Kamal, I would like to know:

1.) if you had any luck getting a preview of the video while capturing it using ffmpeg?
2.) if we can capture both video and audio from a capture device simultaneously using ffmpeg?

wa, its amazing! thanks a lot

wa, its amazing! thanks a lot ,i learned a lot!
im a newbie here! happy to know you!nice forum!

Question

How would you capture in windows from camera on remote I.P.?

Can this be done on Mac OSx

Can this be done on Mac OSx or Windows? If so what are the prerequisites needed?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may link to images on this site using a special syntax

More information about formatting options

CAPTCHA
This question is used to make sure you are a human visitor and to prevent spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.