arecord
Record audio from a soundcard
TLDR
Record a snippet in "CD" quality (finish with
Record a snippet in "CD" quality, with a fixed duration of 10 seconds
Record a snippet and save it as an MP3 (finish with
List all sound cards and digital audio devices
Allow interactive interface (e.g. use
Test your microphone by recording a 5 second sample and playing it back
SYNOPSIS
arecord
[OPTIONS] [FILE]arecord
[-L | -l]
PARAMETERS
-h, --help
Shows help message and exits.
-v, --version
Displays the program version and exits.
-D device
Specifies the PCM device name to use for recording (e.g., hw:0,0, default).
-f format
Sets the sample format (e.g., S16_LE for 16-bit signed little-endian, U8 for 8-bit unsigned).
-r rate
Sets the sample rate in Hz (e.g., 44100, 48000).
-c channels
Sets the number of channels (e.g., 1 for mono, 2 for stereo).
-d duration
Records for a specified duration in seconds.
-t type
Sets the file type (e.g., wav, raw, voc). Default is wav.
-N
Don't touch existing file. If the output file already exists, arecord will not overwrite it.
-M
Use mmap stream. Enables memory-mapped I/O for audio data transfer, which can be more efficient.
-q, --quiet
Suppresses messages during recording.
-L, --list-devices
Lists all sound cards and digital audio devices found on the system.
-l, --list-pcms
Lists all available PCM devices.
FILE
The name of the output file where audio will be saved. Use - for standard output.
DESCRIPTION
arecord is a command-line utility provided by the ALSA (Advanced Linux Sound Architecture) project for recording audio from a sound card or other audio input devices. It allows users to capture audio streams directly from a PCM device, such as a microphone or line-in, and save them to a file in various formats (e.g., WAV, raw). It provides extensive control over recording parameters like sample rate, number of channels, sample format, and recording duration. arecord is commonly used in shell scripts for automated audio capture, for troubleshooting audio input, or for simple, quick recordings without a GUI. Being part of the ALSA utilities, it interacts directly with the kernel's sound drivers, offering low-level access to audio hardware.
CAVEATS
arecord interacts directly with ALSA. On systems primarily using PulseAudio or JACK, you might need to ensure ALSA plugins are configured correctly, or PulseAudio/JACK is set up to expose ALSA devices, otherwise, arecord might not find or use the expected devices.
Permissions issues: Users must typically be part of the 'audio' group to access sound devices directly.
Device availability: If another application is already using the desired audio input device, arecord might report an error like "Device or resource busy."
<I>DEVICE NAMING CONVENTIONS</I>
ALSA devices can be specified using a few conventions with the -D option. default usually refers to the system's default audio device, which might be configured by PulseAudio. For direct hardware access, hw:X,Y is used, where X is the card number (e.g., 0 for the first sound card) and Y is the device number on that card (e.g., 0 for the first digital audio device). You can list available devices using arecord -L or arecord -l.
<I>COMMON SAMPLE FORMATS</I>
The -f option specifies the sample format. Common formats include:
S16_LE: 16-bit signed, little-endian (CD quality standard)
S24_LE: 24-bit signed, little-endian
S32_LE: 32-bit signed, little-endian
U8: 8-bit unsigned (lowest quality, raw byte stream)
Choosing the correct format is important for audio quality and compatibility with playback software.
HISTORY
arecord is an integral part of the ALSA (Advanced Linux Sound Architecture) utilities, which were developed to replace the older OSS (Open Sound System) as the standard sound framework in Linux. ALSA aimed to provide better hardware support, more robust APIs, and improved performance compared to OSS. arecord was introduced as the command-line interface for capturing audio streams using the ALSA PCM (Pulse Code Modulation) interface. Its development has mirrored the evolution of ALSA itself, continually adapting to new audio hardware and software requirements within the Linux ecosystem.