rec
Record audio from sound input devices
TLDR
SYNOPSIS
rec [options] outfile [effects...]
DESCRIPTION
rec is the recording component of SoX (Sound eXchange), the Swiss Army knife of audio processing. It records audio from the default input device (microphone, line-in) to a file in various formats.The output format is typically determined by the file extension. SoX supports dozens of formats including WAV, MP3, FLAC, OGG, AIFF, and raw audio. Format-specific encoding options can be specified for compressed formats.SoX effects can be applied during recording, including silence detection to automatically stop recording, trimming to limit duration, and gain adjustments. Effects are specified after the output filename.rec is equivalent to sox -d (using the default input device) with appropriate defaults for recording. Similarly, play is a playback alias for sox.
PARAMETERS
-r rate
Set sample rate in Hz (e.g., 44100, 48000)-c channels
Set number of channels (1=mono, 2=stereo)-b bits
Set sample size in bits (8, 16, 24, 32)-t type
Specify file type (wav, mp3, flac, ogg, etc.)-e encoding
Set encoding type (signed-integer, unsigned-integer, floating-point, a-law, u-law)-C factor
Set compression factor for output format-S
Show input format, processing progress, and peak-level meter (default for rec)-q
Quiet mode; suppress progress output-V[level]
Set verbosity (0=none, 1=errors, 2=warnings, 3=processing info)-n
Use null file; useful with effects like stat for monitoring without recording--norm[=dBLevel]
Guard against clipping and normalize audio-G
Automatically prevent clipping by applying gain adjustmenttrim start duration
Record from start position for specified durationsilence
Stop recording based on silence detectionfade type in stop out
Apply fade effects
CAVEATS
MP3 encoding requires SoX to be compiled with MP3 support (libmp3lame). Some distributions package this separately due to licensing.The default audio device depends on system configuration and the AUDIODEV environment variable.Recording requires appropriate permissions for audio device access. Users may need to be in the audio group on some systems.Use Ctrl+C to stop recording manually if no duration or silence detection is specified.
