how to record the screen the system sound and audio from the microphone at the same time with ffmpeg?

Solution 1:

Here is answer to your question from these post:

FFMPEG: commandline options to recording audio from mic and speakers

Record program and mic on two separate tracks with ffmpeg

using the PulseAudio utility "pacmd".

Refer this & this Tutorial on youtube

$ 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"

Find your input sources run pacmd list-source-outputs | grep source

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

ffmpeg -f pulse -i [Your input source 1] -map '0' 0.mp3 -f pulse -i [Your input source 2] -map '1' 1.mp3

For example:

$ 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

Solution 2:

Your command is nearly perfect, but what you need to record all the sound is to record the "monitor". Obvioulsy pulse -ac 2 -i 0 points to your mic, not the monitor.

Executing pacmd list-sources might show you the right index. Mine for example is: (just the important parts)

 * index: 0
    name: <alsa_output.pci-0000_1c_00.1.hdmi-stereo-extra3.monitor>
    driver: <module-alsa-card.c>
...
   index: 1
    name: <alsa_output.pci-0000_1e_00.3.analog-stereo.monitor>
    driver: <module-alsa-card.c>
...
   index: 2
    name: <alsa_input.pci-0000_1e_00.3.analog-stereo>
    driver: <module-alsa-card.c>

So you need to decide, which index is the right one for you. It might help to use the Volumecontrol in order to select the correct monitor (in case you have more than one option)

Your command can't work btw, since this part: -i: 0.0 + 0.0 can't be recognized by ffmpeg. It should be "-i :0.0"