Open In App

arecord command in Linux with examples

Last Updated : 07 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

arecord is a command-line sound recorder for ALSA(Advanced Linux Sound Architecture) sound card drivers. It supports several file formats and multiple soundcards with multiple devices. It is basically used to record audio using the command-line interface. Syntax:

arecord [flags] [filename]

If the filename is not specified then it uses Standard input. Options:

  • -h, –help : It is used to show the help messages and exit.
  • –version : Print current version.
  • -l, –list-devices : List all soundcards and digital audio devices.
  • -L, –list-pcms : List all PCMs(Pulse Code Modulation) defined.
  • -D, –device=NAME : Select PCM by name.
  • -q –quiet : Quiet mode. Suppress messages (not sound :).
  • -t, –file-type TYPE File type (voc, wav, raw or au). If this parameter is omitted the WAVE format is used.
  • -c, –channels=# : The number of channels. The default is one channel. Valid values are 1 through 32.
  • -f –format=FORMAT : If no format is given U8 is used.
  • -r, –rate=# : Sampling rate in Hertz. The default rate is 8000 Hertz.
  • -d, –duration=# : Interrupt after # seconds.
  • -s, –sleep-min=# : Min ticks to sleep. The default is not to sleep.
  • -M, –mmap : Use memory-mapped (mmap) I/O mode for the audio stream. If this option is not set, the read/write I/O mode will be used.
  • -N, –nonblock : Open the audio device in non-blocking mode. If the device is busy the program will exit immediately.

Note: It contains various other options that we normally don’t need. If you want to know more about you can simply run following command on the terminal.

arecord --help

Recognized Sample Formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE G723_24 G723_24_1B G723_40 G723_40_1B DSD_U8 DSD_U16_LE DSD_U32_LE DSD_U16_BE DSD_U32_BE Note: Some of these may not be available on selected hardware. Examples:

  • Recording audio through arecord (It will record an audio of 5 secs of U8 format and mp3 type named sample.mp3):
  • Now we will demonstrate how it really sounds like to record.
  • Now we will play that recorded audio using aplay command.(microphone input is off.)

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads