Command line audio recorder for Linux

Default featured post

Recording sound is one the activities which is done commonly in most of the computers. Users do this task for different purposes such as recording their voice, recording from special device such as guitar, piano, etc. or recording from online stream! In this post, I will explain about how to record audio in Linux via command line. Again, as I mentioned before, Linux is such powerful and flexible operating system and for each task in GUI environment, there is equal tool(s) for it to do in command line (text-mode).

In order to record audio in command line you need to install few applications. The first application is Alsamixer which is ncurses based mixer application for use with the ALSA sound card drivers. It supports multiple sound cards with multiple devices. It can be said that Alsamixer is ncurses based version of Amixer application. You can find more about Amixer here. We use this application to set the the capture channel like Microphone, Line In and so on. You also can install Alsamixer, Amixer, Arecord, Aplay (alsa-utils package) with using following command in Debian based distros such as Ubuntu,

$ sudo apt-get install alsa-utils

Now for recording we use Arecord application which is included in alsa-utils package and you could install it with above command. Arecord captures the sound goes through the computer and shows it in the odd form in the terminal output. We should save the output of the application to the file. Therefore, we can pipe the output of Arecord to a type of encoder such as Lame (for .mp3) and Oggenc (for .ogg). As a result, we need to install one encoder. You can install Oggenc with using the following command,

$ arecord -f cd -t raw | oggenc - -r -o OutputFile.ogg

The only remain step is to put the applications together via pipelining to start recording audio. The below line shows the recording command which is made by mixing Arecord and Oggenc.

$ arecord -f cd -t raw | oggenc - -r -o OutputFile.ogg

For more information, please refer to the manual pages of the applications or you can access online from below links,