2

I am having trouble recording the sound of the system and the audio from the microphone at the same time on the computer screen. I'm using the command

ffmpeg -video_size 2880x1800 -framerate 30 -f x11grab -i :0.0 -f pulse -ac 2 -i 0 -f pulse -ac 2 -i 1 output.mkv
3
  • Does this answer your question? How to record desktop with audio on ffmpeg
    – Ajay
    Jul 8, 2020 at 16:56
  • An alternative for screen recording with microphone would be OBS.
    – Sebastian
    Jul 8, 2020 at 19:22
  • 1
    @Ajay I already tested it and it didn't work. records only the sound of the microphone, I would like to record the sound of the system and the microphone. Jul 8, 2020 at 19:29

3 Answers 3

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
3
  • 1
    I'm using Raspbian on Pi 3B. When I run pacmd list-source-outputs | grep source I got 0 source output(s) available. althought I have mic plugged. Is there something wrong? Mar 26, 2021 at 22:28
  • My PC show same result.
    – Ajay
    Mar 27, 2021 at 15:22
  • I can't get this to work when one of the input sources I want to use is the monitor (desktop audio): Option map (set input stream mapping) cannot be applied to input url 3 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to. This seems to make sense since desktop audio is actually an output, but I've tried other options and it seems I can only record the first source I specify. How do I get the desktop audio output onto one of the tracks?
    – Michael
    Jan 17, 2022 at 17:03
1

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"

0

Note: Okay this answer is a complete cop-out since it completely ignores the requirement to use ffmpeg but it works, its great software, and it might help some people.

Anyways, been pulling my hair out forever googling for an answer that is simple to use and provides everything I need.

Install and use Open Broadcaster Software (OBS). Seriously, that's it. Googling it should bring up installation instructions tailored to your machine.

Just record with OBS and it will just make a video with your video source (use Screen Capture) and audio (both system sound and mic) in it. If you only want to record audio, just record without a video source and it will make a blank video with your recording. If you want to record only speaker output and not the mic, simply mute the microphone with a press of a button. Intuitive.

(Note this gives you a video file. It doesn't bother me but if you need an audio file like an mp3 you would have to figure out how to convert the video file you made into an audio file (I don't know how to do that, but there are plenty of resources out there that tell you).)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .