my ~/.bashrc contains the following function

webcamrecord () {
vlc v4l2:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/audio2" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=640 :v4l-height=480 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100 --sout="#transcode{vfilter=adjust{gamma=1.5},vcodec=theo,vb=2000,scale=0.67,acodec=vorb,ab=128,channels=2}:standard{access=file,mux=ogg,dst="output_file.ogg"}" 

The command works beautifully to record directly from my webcam, with one or two flaws. First, the video produced moves too quickly, between twice and three times the normal rate.

Also, there is no audio. This is less of an issue, but I would still like to fix this.

Can someone help me debug this command, so as to fix these issues?


This one-liner worked for me, with audio and video:

vlc v4l2:// :input-slave=alsa:// :v4l-vdev="/dev/video0" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=480 :v4l-height=360 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100 --sout="#transcode{vcodec=theo,vb=2000,fps=12,scale=0.67,acodec=vorb,ab=90,channels=1,samplerate=44100}:standard{access=file,mux=ogg,dst=output.ogg}"

You could also try this one:

vlc v4l2:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/pcm" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=480 :v4l-height=360 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100 --sout="#transcode{vcodec=theo,vb=2000,fps=12,scale=0.67,acodec=vorb,ab=90,channels=1,samplerate=44100}:standard{access=file,mux=ogg,dst=output.ogg}"

Your experience may vary, depending on your hardware. Good luck!


Out of curiosity, are you sure that the audio source is the proper source?

Secondly (again, just a question) why aren't you using ffmpeg to stream the video instead?
Something like but not quite:

ffmpeg -b 100K -an -f video4linux2 -s 320x240 -r 10 -i /dev/audio2 -i /dev/video0 -b 100K -f ogg - | mplayer - -idle -demuxer ogg

Swap the audio input and video input to your liking and then mess around with the actual file conversion, i'm a bit rusty on ffmpeg and mplayer but it's doable. + a friend did it with raspberry pi with ~20fps @1080p so you should be fine with standard equipment via this method :)


Get an overview of all devices (in this example: /dev/video0):

v4l2-ctl --list-devices

Check the availible formats:

v4l2-ctl --list-formats-ext -d /dev/video0

Determ sound source (card: 0 ..., device: 1... is equal to hw:0,1. In this example hw:0,0):

arecord -l

Record video + audio, directly to file:

cvlc v4l2:///dev/video0:width=640:height=480 :input-slave=alsa://hw:0,0 --sout="#transcode{vcodec=theo,vb=2000,fps=20,scale=1.0,acodec=vorb,ab=90,channels=1,samplerate=44100}:standard{access=file,mux=ogg,dst=output.ogg}"

Same but with live video:

cvlc v4l2:///dev/video0:width=640:height=480 :input-slave=alsa://hw:0,0 --sout="#transcode{vcodec=theo,vb=2000,fps=20,scale=1.0,acodec=vorb,ab=90,channels=1,samplerate=44100}:duplicate{dst=display,dst=standard{access=file,mux=ogg,dst=output.ogg}}"  

You could change cvlc back to vlc if you want to have controls + menu.

More options with the v4l2 module in VLC.


Unable to get consistent results or find a minimal example, I tried to read the instructions grepping for things like this,

 vlc --longhelp --advanced | grep v4l | grep dev

ultimately this seems to work as a minimal example,

 vlc  alsa://plughw:1,0 --input-slave=v4l2:///dev/video0

while I did not check sync or quality at all, indeed I was curious to see what audio and video feedback I could produce pointing camera at screen and turning on spectrometer, it may get both channels to play and you can tweak from there. You can get your appropriate devices from the prior responses AFAICT.

I have this version:

VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
VLC version 2.2.2 Weatherwax (2.2.2-0-g6259d80)
Compiled by buildd on lgw01-09.buildd (Aug  8 2017 18:59:52)
Compiler: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.