Skip to content

Instantly share code, notes, and snippets.

@porjo
Last active May 3, 2022 22:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porjo/8b92bf27c6109159e482810d986e41d7 to your computer and use it in GitHub Desktop.
Save porjo/8b92bf27c6109159e482810d986e41d7 to your computer and use it in GitHub Desktop.
Capture video + audio using EasyCAP USB analog to digital converter
  • Capture audio from device1 (hw:1)
  • Capture video from /dev/video0 as PAL (720x576 50hz)
  • de-interlace (yadif)
  • encode video using 'fast' preset (using slow was getting dropped frames)
  • encode audio as AAC 128kb

software encoding

ffmpeg \
  -f alsa -ac 2 -thread_queue_size 512 -i hw:1 \
  -f v4l2 -standard PAL -thread_queue_size 512 -i /dev/video0 \
  -vf yadif -c:v libx264 -preset fast -crf 23 \
  -c:a aac -b:a 128k \
  output.mkv

hardware encoding using VAAPI

ffmpeg \
  -f alsa -ac 2 -thread_queue_size 1024 -i hw:1 \
  -f v4l2 -standard PAL -thread_queue_size 1024 -i /dev/video0 \
  -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' -threads 4 -vcodec h264_vaapi -qp:v 23 \
  -c:a aac -b:a 128k \
  output.mkv

No deinterlacing with hardware encoding :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment