[FFmpeg-user] Recording audio from mic and speakers from commandline

Mohan G mail2mohan81 at gmail.com
Sat Oct 17 12:53:54 CEST 2015

Finally I found a way to achieve what I wanted, using the PulseAudio
utility **"pacmd"**.

$ pacmd list-sources|awk '/index:/ {print $0}; /name:/ {print $0};
/device\.description/ {print $0}'

Run above command to get the indexes of all the system recording
interfaces, with respect to PulseAudio. Sample output given below.

        index: 0
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor>
            device.description = "Monitor of Built-in Audio Analog Stereo"
      * index: 1
        name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
            device.description = "Built-in Audio Analog Stereo"
Run the following command to start recording using the ffmpeg application.

$ ffmpeg -f alsa -i pulse -f alsa -i default -acodec libmp3lame -map
0:0 -map 1:0 outfile.mkv

Now, get the indexes of the ffmpeg application interfaces, with
respect to PulseAudio. Then set each of this 'application interface
index' to the desired 'recording interface index'.

$ pacmd list-source-outputs|tr "\n" " "| awk 'BEGIN {RS="index:"};
/application.process.binary = "ffmpeg"/ {print $0 }' |awk '{print
"pacmd move-source-output " $1 " " (NR-1)}'|bash

This solution works only when no other instance of "ffmpeg" is running
on the system.

The solution could have been better, if I could specify the
recording-interfaces along with the "ffmpeg" command itself. Please
let me know if it is possible.

- Mohan

More information about the ffmpeg-user mailing list