I’m trying to record a video with sound through FFmpeg, and while it records the system sounds just fine, it doesn’t record the microphone (in fact, it crashes on doing so!). The strange thing is that if I use arecord, it works just perfectly, but through ffmpeg it crashes.
This is the command that I use to launch FFmpeg:
/usr/bin/ffmpeg \ -f x11grab \ -xerror \ -r 25 \ -s 588x572 \ -i :0.0+798,115 \ -vcodec libvpx \ -f alsa \ -i hw:1,0 \ -acodec pcm_s16le \ -y /home/dainius/temp/qx11grab-160723.avi
This is the log of ffmpeg crashing:
[x11grab @ 0x6376d0] device: :0.0+798,115 -> display: :0.0 x: 798 y: 115 width: 588 height: 572 [x11grab @ 0x6376d0] shared memory extension found [x11grab @ 0x6376d0] Estimating duration from bitrate, this may be inaccurate Input #0, x11grab, from ':0.0+798,115 ': Duration: N/A, start: 1288271247.509504, bitrate: 269068 kb/s Stream #0.0: Video: rawvideo, bgra, 588x572, 269068 kb/s, 25 tbr, 1000k tbn, 25 tbc [alsa @ 0x646f10] cannot set channel count to 1 (Invalid argument) hw:1,0: Input/output error
If I change the "-i hw:1,0 " part to "-i hw:0,0 " it records the system sounds, and does it just fine. But both of these commands succeed in arecord:
arecord -d 10 -f cd -t wav -D hw:0,0 test.wav arecord -d 10 -f cd -t wav -D hw:1,0 test.wav
So what’s wrong? Why does ffmpeg report an error, yet arecord does it just fine?
Another question that is related to this topic: is there a way to use ffmpeg to record both system sounds and the microphone? Or mix two sources into one with ALSA?
For the record, here is my ALSA configuration (using OpenSUSE 11.3):