Why can't record audio in the speaker and mic at the same time?
List sound card info on my pc.
pacmd list-sources |grep name: name: <alsa_input.usb-SN0002-02.analog-mono> name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor> name: <alsa_input.pci-0000_00_1b.0.analog-stereo>Set variables to simply next command:
speaker=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
mic=alsa_input.usb-SN0002-02.analog-monoRecord a music playing on the speaker:
ffmpeg -use_wallclock_as_timestamps 1 -f pulse -i $speaker -acodec copy /tmp/out.mkvRecord voice speaking to the mic:
ffmpeg -use_wallclock_as_timestamps 1 -f pulse -i $mic -acodec copy /tmp/out.mkvNow to record the sound both in the speaker and mic:
ffmpeg -use_wallclock_as_timestamps 1 \ -f pulse -i $speaker -f pulse -i $mic \ -acodec copy /tmp/out.mkvIt output info on the screen:
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor': Duration: N/A, start: 1606130053.472713, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'alsa_input.usb-SN0002.analog-mono': Duration: N/A, start: 1606130053.597432, bitrate: 1536 kb/s Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/sIt record no voice speaking to the mic recorded in /tmp/out.mkv ,only sound playing on speaker recorded?Why ffmpeg guess the Channel Layout for Input Stream?
I have tried the method on superuser:
ffmpeg -use_wallclock_as_timestamps 1 \ -f pulse -i $speaker -f pulse -i $mic \ -acodec libmp3lame -map 0:0 -map 1:0 /tmp/out.mkvIt record nothing ,both sound on the speaker and mic can't be recorded.
1 Answer
Usually it's not possible to record audio from two sources at once. You have first to use this solution to route audio from your microphone into the speakers and then record the mix of what you hear in the speakers.