I am using ffmpeg version 2.4.7 on Fedora-21 workstation. I want to record audio, simultaneously from microphone and speakers as separate streams. I am using the following command for it.

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

But after executing this command in terminal, I have to goto "Volume Control" settings in GUI, then goto "Recording" tab, change the "capture from" of one channel to "Built-in Audio Analog Stereo" (i.e., Microphone) and the "capture from" of another channel to "Monitor of Built-in Audio Analog Stereo" (i.e., Speakers).

But how can this be done completely from command-line, for automating it to use in scripts.

1 Answer 1


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

This tutorial help me

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

Run above command to get the names of all the system recording interfaces. 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"

Now, run the following command to recording audio from mic and speakers simultaniously.

$ ffmpeg -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo -acodec libmp3lame -map 0:0 -map 1:0 outfile.mkv
  • thank you!!!! I just wanted to let people know a) this works. b) I tried to use mp3 and it didn't - for some reason, it only works with this mkv wierd format.
    – Dan Erez
    Aug 12, 2020 at 18:34
  • I'm using RPi with Raspbian and the output of first command returns only alsa_output's (2 devices) and when I tried to record no sound captured. Can you help me what's wrong with this? Mar 26, 2021 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.