#StackBounty: #shell-script #audio #video #ffmpeg Script for ffmpeg webcam audio video recording

Bounty: 50

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.

Script:

echo "Short title (and/or ENTER):"
read title
recdir=$HOME/Videos/0_Integrate/test-webcam
# Check if the default directory exists
if [ -d $recdir ] 
then
    path=$recdir
else
    # If not, write to $HOME
    path=$HOME
fi
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
echo
echo
# Show where and which file was recorded
echo "Recorded to file:"
echo -e "e[1;31m$filenamee[0m"
echo

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]


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.