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.


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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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