I've bought the very popular Logitech C920 for creating YouTube videos with ffmpeg.

My desire is to build a script for easy recording without bothering with the powerful but rather cryptic ffmpeg commands. I've come pretty far, however I'm now trying for hours to solve basically three problems:

(1) show the video, while recording
(2) record the stereo audio in good quality
(3) display an VU-meter

For displaying the video I've found ffplay instead of ffmpeg, however, this would require another command so I'm not sure how to do this in order to start two commands at the same time (and be sure that this are synchronized). I usually use the mpv player in an i3wm desktop environment.

The audio record should be included into the video-file, and it would be desirable push the audio-quality as high as possible, and reasonable (considering the hardware).

Since the setup is not intended to be used for live-streaming, it is not important to make the final encoding on the fly. If an additional step, at the end of the video-recording, would lead to better results, this variant is preferable. The central focus is to produce a video-file which is optimized to have good playback quality on mid-range to low-cost hardware (i.e. no artefacts) for YouTube-viewers without fast internet connections.


echo "Short title (and/or ENTER):"
read title
# Check if the default directory exists
if [ -d $recdir ] 
    # If not, write to $HOME
echo "Recording now!"
echo "To File:"
# File-name and -location composition
filename=$(date +"$path/%Y%m%d-%H%M_$title.mp4")
echo "$filename"
# Recording command
ffmpeg -f video4linux2 -framerate 30 -video_size 864x480 -input_format h264 -i /dev/video0  $filename
# Show where and which file was recorded
echo "Recorded to file:"
echo -e "\e[1;31m$filename\e[0m"

I've consulted the official (this, this and this ) as well as other sources (e.g. this, this, and this), without much luck finding an understandable (for casual users) and complete guide for setting this up.

[EDIT Found possible problem why my audio is not recorded. The VU-meter doesn't react to microphone input. See screenshot: enter image description here \EDIT]

  • Not an answer, but word of advice: If you want to do this on a daily basis, save yourself a lot of headache and buy a dedicated camera. With an external microphone input, if necessary. Or use your smartphone. From my experience, "webcam", "ffmpeg" and "audio video synchronization" is more an art than science. You can try ffmpeg -f video4linux2 -framerate 30 -video_size 864x480 -input_format h264 -i /dev/video0 -f pulse -ac 2 -i default -c copy -y -f mpegts - | tee "$filename" | ffplay -. Beware of lag. – Hermann Jul 17 at 18:36
  • As for the audio, I recommend pavucontrol. In the configuration tab, disable all devices except for your speakers (set them to output only) and your webcam (set it to input only). Keep pavucontrol open for a VU-meter. – Hermann Jul 17 at 18:38
  • @Hermann : Thank you (-: As you expected, there is lag (I'm not streaming, the recording is laggy). Also the audio is not recording. Probably there is some other issue. Is it possible that pulseaudio is conflicting or not set properly. Do you have any Idea how I could further proceed? – alex Jul 23 at 12:21
  • Double-check that there is only exactly one device configured for input (please excuse the German localization). While ffmpeg is recording, check that it actually selected the configured device (the button next to the title). If the meter is stuck at zero, you may need to use alsamixer to un-mute the input (pulseaudio controls the level, but not the mute-state). Do not forget to check for hardware mute switches. – Hermann Jul 23 at 14:17

Your Answer

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

Browse other questions tagged or ask your own question.