FFMPEG: commandline options to recording audio from mic and speakers

7,620

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
Share:
7,620

Related videos on Youtube

Mohan
Author by

Mohan

Updated on September 18, 2022

Comments

  • Mohan
    Mohan almost 2 years

    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.

  • Dan Erez
    Dan Erez almost 4 years
    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.
  • Mamdouh Saeed
    Mamdouh Saeed over 3 years
    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?