Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 01-13-2016, 04:35 PM   #1
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 536

Rep: Reputation: 215Reputation: 215Reputation: 215
Record HD videos in command line

Is this even possible? I have Logitech Webcam C270. I tried the following ffmpeg commands but they produce poor quality videos, not HD:
ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
ffmpeg -i /dev/video0 -vcodec copy -acodec ac3 -ab 128k -f matroska video.mkv
ffmpeg -i /dev/video0 -vcodec mjpeg -r 10 -s 640x480 file.avi
I am not an expert on video processing, codecs etc. I am not trying to shoot a professional video, just a short clip for youtube. I tried guvcview and in my opinion it produces much better quality videos than the above ffmpeg examples and although it also can be run in command line I prefer ffmpeg because it's more versatile and is installed everywhere.

Last edited by average_user; 01-13-2016 at 04:39 PM.
Old 01-13-2016, 08:33 PM   #2
Registered: Mar 2008
Posts: 20,304

Rep: Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213Reputation: 3213
Some notes maybe.

Start with listing the modes. Then maybe try their example. ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv


Uses the video4linux2 (or simply v4l2) input device to capture live input such as from a webcam. See the v4l2 input device documentation for more information.
List devices

To list the supported, connected capture devices you can use the v4l-ctl tool. This example shows two connected webcams: /dev/video0 and /dev/video1.

$ v4l2-ctl --list-devices
USB2.0 PC CAMERA (usb-0000:00:1d.7-1):

UVC Camera (046d:0819) (usb-0000:00:1d.7-2):

List device capabilities

To list available formats (supported pixel formats, video formats, and frame sizes) for a particular input device:

$ ffmpeg -f v4l2 -list_formats all -i /dev/video0

[video4linux2,v4l2 @ 0xf07d80] Raw : yuyv422 : YUV 4:2:2 (YUYV) : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360
[video4linux2,v4l2 @ 0xf07d80] Compressed: mjpeg : MJPEG : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360

Alternatively you could use v4l2-ctl --list-formats-ext to list available formats.
Encoding example

Example to encode video from /dev/video0:

ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv

Adjusting camera functions

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>

Last edited by jefro; 01-13-2016 at 08:35 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Command line tool to record audio rmcellig Linux - Software 1 03-21-2012 09:22 PM
[SOLVED] How to record a command line session to a file? Telengard Linux - Software 5 05-19-2011 07:18 PM
LXer: get-flash-videos - A command line program to download flash videos LXer Syndicated Linux News 0 04-06-2010 02:20 PM
awk command line: blank line record sep, new line field sep robertmarkbram Programming 4 02-21-2010 06:25 AM
Command line youtube videos for new linux users stratotak Linux - Newbie 0 01-14-2009 01:32 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:17 AM.

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