If your webcam is USB, the kernel should automatically load the proper driver. If this is the case, check dmesg after you plug your webcam in.
dmesg | tail
V4L2 is the second version of Video For Linux which is a video capturing API for Linux.
Uses the video4linux2 (v4l2) input device to capture live input such as from a webcam.
To list available formats (supported pixel formats, video formats, and frame sizes) for a particular input device:
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 003: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 002: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
strong@foreverstrong:~$
strong@foreverstrong:~$ ls /dev/ | grep video
video0
strong@foreverstrong:~$
Webcam support in Linux is mainly provided by the Linux UVC Project’s UVC driver. This aims to provide a universal driver in the same way that a generic driver handles USB storage devices (memory sticks, hard drives etc). However, other drivers also exist that may allow more devices to be used. When looking to purchase a webcam for use with Ubuntu, you should look for a UVC compatible camera. The Linux-UVC project has a good list of UVC compatible webcams.
Ubuntu aims to provide ‘out-of-the-box’ or ‘just-works’ functionality for webcams. This means that you should be able to plug-in your webcam and use it straight away: no driver disks or installation. To test whether or not your webcam works in this way, install Cheese, a GNOME program for capturing video and stills from a webcam. It can also apply some special effects.
In some cases your media player will need to know the video and audio device files for your webcam.
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 2月 2 16:11 /dev/video0
strong@foreverstrong:~$
strong@foreverstrong:~$ ls -l /dev/audio*
ls: cannot access '/dev/audio*': No such file or directory
strong@foreverstrong:~$
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ ffmpeg
The program 'ffmpeg' is currently not installed. You can install it by typing:
sudo apt install ffmpeg
strong@foreverstrong:~$
strong@foreverstrong:~$ sudo apt install ffmpeg
[sudo] password for strong:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libllvm4.0
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
libavdevice-ffmpeg56
Suggested packages:
ffmpeg-doc
The following NEW packages will be installed:
ffmpeg libavdevice-ffmpeg56
0 upgraded, 2 newly installed, 0 to remove and 180 not upgraded.
Need to get 1,360 kB of archives.
After this operation, 2,149 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libavdevice-ffmpeg56 amd64 7:2.8.15-0ubuntu0.16.04.1 [70.7 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 ffmpeg amd64 7:2.8.15-0ubuntu0.16.04.1 [1,289 kB]
Fetched 1,360 kB in 10s (135 kB/s)
Selecting previously unselected package libavdevice-ffmpeg56:amd64.
(Reading database ... 258275 files and directories currently installed.)
Preparing to unpack .../libavdevice-ffmpeg56_7%3a2.8.15-0ubuntu0.16.04.1_amd64.deb ...
Unpacking libavdevice-ffmpeg56:amd64 (7:2.8.15-0ubuntu0.16.04.1) ...
Selecting previously unselected package ffmpeg.
Preparing to unpack .../ffmpeg_7%3a2.8.15-0ubuntu0.16.04.1_amd64.deb ...
Unpacking ffmpeg (7:2.8.15-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
/sbin/ldconfig.real: /opt/intel/common/mdf/lib64/igfxcmrt64.so is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-x11.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-drm.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfxhw64.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfx.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-glx.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libigdgmm.so.1 is not a symbolic link
Processing triggers for man-db (2.7.5-1) ...
Setting up libavdevice-ffmpeg56:amd64 (7:2.8.15-0ubuntu0.16.04.1) ...
Setting up ffmpeg (7:2.8.15-0ubuntu0.16.04.1) ...############################................................................]
Processing triggers for libc-bin (2.23-0ubuntu10) ...
/sbin/ldconfig.real: /opt/intel/common/mdf/lib64/igfxcmrt64.so is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-x11.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-drm.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfxhw64.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libmfx.so.1 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libva-glx.so.2 is not a symbolic link
/sbin/ldconfig.real: /opt/intel/mediasdk/lib64/libigdgmm.so.1 is not a symbolic link
strong@foreverstrong:~$
The video stream from the USB camera could be captured and saved to the output_video.avi file using the following command:
ffmpeg -f video4linux2 -r 30 -s 640x480 -i /dev/video0 output_video.avi
assuming that /dev/video0
is the webcam device file.
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~/ffmpeg$ ffmpeg -f video4linux2 -r 30 -s 640x480 -i /dev/video0 output_video.avi
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 5386.626378, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Output #0, avi, to 'output_video.avi':
Metadata:
ISFT : Lavf56.40.101
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc56.60.100 mpeg4
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
frame= 215 fps= 15 q=5.3 Lsize= 294kB time=00:00:07.16 bitrate= 336.2kbits/s
video:283kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.772538%
strong@foreverstrong:~/ffmpeg$
strong@foreverstrong:~/ffmpeg$ ll
total 304
drwxrwxr-x 2 strong strong 4096 2月 2 17:40 ./
drwxr-xr-x 29 strong strong 4096 2月 2 17:40 ../
-rw-rw-r-- 1 strong strong 301178 2月 2 17:41 output_video.avi
strong@foreverstrong:~/ffmpeg$
[setupvars.sh] OpenVINO environment initialized
strong@foreverstrong:~$ v4l2-ctl --list-devices
UVC Camera (046d:0825) (usb-0000:00:14.0-1):
/dev/video0
strong@foreverstrong:~$
strong@foreverstrong:~$ ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[video4linux2,v4l2 @ 0x15779c0] Raw : yuyv422 : YUYV 4:2:2 : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360 752x416 800x448 800x600 864x480 960x544 960x720 1024x576 1184x656 1280x720 1280x960
[video4linux2,v4l2 @ 0x15779c0] Compressed: mjpeg : Motion-JPEG : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360 752x416 800x448 800x600 864x480 960x544 960x720 1024x576 1184x656 1280x720 1280x960
/dev/video0: Immediate exit requested
strong@foreverstrong:~$
strong@foreverstrong:~$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 320x176
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 432x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 544x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 752x416
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 800x448
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 864x480
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 960x544
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 960x720
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1024x576
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1184x656
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)
Index : 1
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : Motion-JPEG
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 320x176
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 432x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 544x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 640x360
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 752x416
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 800x448
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 864x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 960x544
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 960x720
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1024x576
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1184x656
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.200s (5.000 fps)
strong@foreverstrong:~$
Example to encode video from /dev/video0:
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output_data.mkv
strong@foreverstrong:~/ffmpeg$ ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output_data.mkv
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 428832.003112, bitrate: 122880 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 122880 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x250c140] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x250c140] profile High 4:2:2, level 3.0, 4:2:2 8-bit
[libx264 @ 0x250c140] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'output_data.mkv':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv422p, 640x480, q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 59 fps= 17 q=28.0 size= 74kB time=00:00:00.04 bitrate=15142.8kbits
frame= 68 fps= 17 q=28.0 size= 145kB time=00:00:02.32 bitrate= 511.9kbits/
frame= 76 fps= 17 q=28.0 size= 211kB time=00:00:02.80 bitrate= 618.2kbits/
frame= 85 fps= 17 q=26.0 size= 277kB time=00:00:03.36 bitrate= 675.9kbits/
frame= 93 fps= 17 q=26.0 size= 337kB time=00:00:03.84 bitrate= 719.3kbits/
frame= 101 fps= 17 q=26.0 size= 395kB time=00:00:04.32 bitrate= 750.0kbits/
frame= 110 fps= 17 q=26.0 size= 462kB time=00:00:04.84 bitrate= 782.1kbits/
frame= 118 fps= 17 q=26.0 size= 520kB time=00:00:05.36 bitrate= 794.2kbits/
frame= 127 fps= 17 q=28.0 size= 587kB time=00:00:05.88 bitrate= 817.1kbits/
frame= 135 fps= 17 q=28.0 size= 643kB time=00:00:06.36 bitrate= 828.7kbits/
frame= 143 fps= 17 q=28.0 size= 701kB time=00:00:06.84 bitrate= 839.3kbits/
frame= 152 fps= 17 q=28.0 size= 764kB time=00:00:07.40 bitrate= 845.3kbits/
frame= 160 fps= 17 q=28.0 size= 824kB time=00:00:07.88 bitrate= 857.0kbits/
frame= 169 fps= 17 q=26.0 size= 887kB time=00:00:08.44 bitrate= 861.0kbits/
frame= 177 fps= 17 q=26.0 size= 944kB time=00:00:08.92 bitrate= 867.3kbits/
frame= 185 fps= 17 q=28.0 size= 1002kB time=00:00:09.40 bitrate= 873.6kbits/
frame= 194 fps= 17 q=26.0 size= 1069kB time=00:00:09.92 bitrate= 882.4kbits/
frame= 202 fps= 17 q=26.0 size= 1126kB time=00:00:10.44 bitrate= 883.5kbits/
frame= 210 fps= 17 q=26.0 size= 1183kB time=00:00:10.92 bitrate= 887.8kbits/
frame= 219 fps= 17 q=28.0 size= 1250kB time=00:00:11.44 bitrate= 895.5kbits/
frame= 227 fps= 17 q=26.0 size= 1308kB time=00:00:11.92 bitrate= 899.0kbits/
frame= 236 fps= 17 q=28.0 size= 1375kB time=00:00:12.48 bitrate= 902.5kbits/
frame= 244 fps= 17 q=28.0 size= 1433kB time=00:00:12.96 bitrate= 905.9kbits/
frame= 252 fps= 17 q=28.0 size= 1490kB time=00:00:13.44 bitrate= 908.4kbits/
frame= 261 fps= 17 q=26.0 size= 1553kB time=00:00:14.00 bitrate= 908.6kbits/
frame= 269 fps= 17 q=28.0 size= 1610kB time=00:00:14.48 bitrate= 911.1kbits/
frame= 277 fps= 17 q=28.0 size= 1672kB time=00:00:14.96 bitrate= 915.4kbits/
frame= 286 fps= 17 q=26.0 size= 1734kB time=00:00:15.52 bitrate= 915.2kbits/
frame= 294 fps= 17 q=26.0 size= 1791kB time=00:00:16.00 bitrate= 917.0kbits/
frame= 303 fps= 17 q=28.0 size= 1857kB time=00:00:16.52 bitrate= 921.0kbits/
frame= 311 fps= 17 q=26.0 size= 1930kB time=00:00:17.00 bitrate= 929.9kbits/
frame= 319 fps= 17 q=26.0 size= 1987kB time=00:00:17.52 bitrate= 929.2kbits/
frame= 328 fps= 17 q=28.0 size= 2054kB time=00:00:18.04 bitrate= 932.6kbits/
frame= 336 fps= 17 q=28.0 size= 2112kB time=00:00:18.52 bitrate= 934.1kbits/
frame= 345 fps= 17 q=26.0 size= 2176kB time=00:00:19.08 bitrate= 934.1kbits/
frame= 353 fps= 17 q=28.0 size= 2233kB time=00:00:19.56 bitrate= 935.2kbits/
frame= 361 fps= 17 q=28.0 size= 2294kB time=00:00:20.04 bitrate= 937.9kbits/
frame= 368 fps= 16 q=-1.0 Lsize= 2746kB time=00:00:23.84 bitrate= 943.6kbits
/s
video:2743kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.121628%
[libx264 @ 0x250c140] frame I:2 Avg QP:17.12 size: 38360
[libx264 @ 0x250c140] frame P:366 Avg QP:23.67 size: 7462
[libx264 @ 0x250c140] mb I I16..4: 9.0% 80.2% 10.8%
[libx264 @ 0x250c140] mb P I16..4: 0.6% 2.6% 0.1% P16..4: 56.9% 14.7% 21.7% 0.0% 0.0% skip: 3.3%
[libx264 @ 0x250c140] 8x8 transform intra:78.1% inter:93.8%
[libx264 @ 0x250c140] coded y,uvDC,uvAC intra: 69.1% 99.8% 97.0% inter: 23.2% 93.3% 40.5%
[libx264 @ 0x250c140] i16 v,h,dc,p: 6% 6% 2% 87%
[libx264 @ 0x250c140] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 11% 35% 8% 7% 6% 7% 7% 8%
[libx264 @ 0x250c140] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 14% 29% 8% 8% 7% 6% 6% 5%
[libx264 @ 0x250c140] i8c dc,h,v,p: 70% 7% 11% 12%
[libx264 @ 0x250c140] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x250c140] ref P L0: 42.6% 5.2% 31.3% 20.9%
[libx264 @ 0x250c140] kb/s:937.52
strong@foreverstrong:~/ffmpeg$
Brightness, zoom, focus, etc, can be adjusted with v4l2-ctl. Display all controls and their menus:
v4l2-ctl -L
Then adjust the value:
v4l2-ctl -c <option>=<value>
Webcam
https://help.ubuntu.com/community/Webcam