ALSA buffer xrun induced by low quality source in ffmpeg capture

Found a partial solution in using two separate ffmpeg processes, as suggested in this thread: https://trac.ffmpeg.org/ticket/615 Specifically, this comment: https://trac.ffmpeg.org/ticket/615#comment:13

The separate audio and video files will have to be put together, later.

Recording video in ffmpeg and audio in Audacity was not useful due to sync problems, written up here: https://video.stackexchange.com/questions/14809/sync-up-ffmpeg-rawvideo-recording-and-audacity-alsa-recording

Hopefully the two ffmpeg processes record at the same rate, unlike ffmpeg and Audacity.

Edit: Two ffmpeg processes probably will not produce two files of the same length. It seems that ffmpeg automatically strips out dead space from video, but not audio.


I was able to solve this problem by adding the -thread_queue_size 1024 was able to solve this problem by adding the option for both the video input and the audio input. Here is my full line:

ffmpeg -f rawvideo -video_size 720x480 -thread_queue_size 1024 \
  -pixel_format uyvy422 -framerate 29.97 -i - -f alsa -thread_queue_size 1024 \
  -i hw:1 -preset slow -c:v libx264 -aspect 4:3 -strict -2 -y -threads 4 output.mp4