Ask Your Question
1

Recording audio from mic and speakers from commandline

asked 2015-03-19 18:13:55 -0600

Mohan G gravatar image

I am using Fedora-21 workstation. I want to record audio, sometimes from my mic and sometimes from speakers. I am using the following command for it.

ffmpeg -f alsa -i pulse -c:a libmp3lame output.mkv

To record from my Mic: After executing this command, I goto "Volume Control" settings in GUI, then goto "Recording" tab, change it to "Built-in Audio Analog Stereo".

To record from my Speakers: After executing this command, I goto "Volume Control" settings in GUI, then goto "Recording" tab, change it to "Monitor of Built-in Audio Analog Stereo".

But how can this be done completely from command-line, for automating it using scripts.

P.S.: I want to integrate this solution with few other thing that I do using ffmpeg. So I would prefer a solution using ffmpeg.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-10-17 05:21:15 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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 recording interfaces. Sample output is 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"

To record from my Speakers: use "Monitor of Built-in Audio Analog Stereo"

 $ ffmpeg -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -c:a libmp3lame output.mkv

To record from my Mic: use "Built-in Audio Analog Stereo"

 $ ffmpeg -f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo -c:a libmp3lame output.mkv
edit flag offensive delete link more
0

answered 2015-03-20 00:43:32 -0600

aeperezt gravatar image

you can capture alsa something like this:

ffmpeg -f alsa -ac 2 -i pulse output.wav

or

ffmpeg -f alsa -i hw:1 -t 30 out.wav

or

ffmpeg -f alsa -ac 1 -ar 44100 -i hw:0 -t 30 out.wav

More information on: https://trac.ffmpeg.org/wiki/Capture/ALSA

Hope it helps

edit flag offensive delete link more

Comments

None of these are recording audio from Speakers.

Mohan G gravatar imageMohan G ( 2015-03-20 02:00:00 -0600 )edit

What you need to do is use those options but set alsamixer loopback enabled that will do the trick.

aeperezt gravatar imageaeperezt ( 2015-03-20 09:39:30 -0600 )edit

can u explain what you mean by 'set alsamixer loopback enabled'.

Mohan G gravatar imageMohan G ( 2015-03-20 13:24:46 -0600 )edit

Using alsamixer on the terminal there is an loopback option that will mix all input sound

aeperezt gravatar imageaeperezt ( 2015-03-20 14:08:41 -0600 )edit

That option is available only if I do 'modprobe snd-aloop'. But enen then I need to manually select the option in the menu. This will not work for me as I am looking for automating it to use in scripts.

Mohan G gravatar imageMohan G ( 2015-03-20 15:19:18 -0600 )edit
0

answered 2015-03-19 23:05:27 -0600

iddnna gravatar image

alsa-utils have a simple method for record audio from microphone using the terminal, maybe this can be useful

arecord recording.mp3

if you need more info just run in the terminal => man arecord

regards :)

edit flag offensive delete link more

Comments

I know about arecord. I am looking for something (using ffmpeg) to record mic as well as speakers, from CLI.

Mohan G gravatar imageMohan G ( 2015-03-19 23:12:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-19 18:13:55 -0600

Seen: 7,713 times

Last updated: Oct 17 '15