LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

rec

Record audio from sound input devices

TLDR

Record audio to a file from the default input
$ rec [output.wav]
copy
Record for a specific duration (10 seconds)
$ rec [output.wav] trim 0 10
copy
Record in a specific format (MP3)
$ rec [output.mp3]
copy
Record with specific sample rate and channels
$ rec -r 44100 -c 2 [output.wav]
copy
Record until silence is detected
$ rec [output.wav] silence 1 0.1 1% 1 1.0 1%
copy
Record 16-bit audio
$ rec -b 16 [output.wav]
copy
Monitor input levels without recording
$ rec -n stat
copy
Record with normalization to prevent clipping
$ rec --norm [output.wav]
copy

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 adjustment
trim start duration
Record from start position for specified duration
silence
Stop recording based on silence detection
fade 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.

SEE ALSO

sox(1), play(1), soxi(1), arecord(1), ffmpeg(1)

Copied to clipboard
Kai