Notes to Self

Alex Sokolsky's Notes on Computers and Programming

ffmpeg

ffmpeg man page, use with webcam.

Prerequisites

Know thyself.

Identify the audio recording devices available with pacmd list-sources. I picked alsa_input.usb-046d_HD_Pro_Webcam_C920_CDF1191F-02.analog-stereo.

Identify the video formats available using

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

or

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

I picked MJPG 1920x1080.

Recording

This will:

ffmpeg -y \
    -f v4l2 -t 10 -framerate 30 -video_size 1920x1080 -input_format mjpeg -i /dev/video4 \
    -f pulse -t 10 -sample_rate 44100 -channels 1 -i alsa_input.usb-046d_HD_Pro_Webcam_C920_CDF1191F-02.analog-stereo \
    -c:v libx264 -preset faster -c:a ac3_fixed \
    -metadata title="From my desk" out.mkv

To avoid re-compression:

ffmpeg \
    -f v4l2 -framerate 30 -video_size 1280x720 -input_format mjpeg -i /dev/video0 \
    -c copy out.mkv

Then:

Take a picture

ffmpeg -f v4l2 -video_size 1280x720 -i /dev/video0 -frames 1 out.jpg

Streaming

https://trac.ffmpeg.org/wiki/StreamingGuide

More Utilities

Use ffprobe to display stream info:

ffprobe out.mkv

Simple player:

ffplay /dev/video0