Linux command
rec 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Record audio
rec [output.wav]
Record for a specific duration
rec [output.wav] trim 0 10
Record in a specific format
rec [output.mp3]
Record with specific sample rate
rec -r 44100 -c 2 [output.wav]
Record until silence is detected
rec [output.wav] silence 1 0.1 1% 1 1.0 1%
Record 16-bit audio
rec -b 16 [output.wav]
Monitor input levels
rec -n stat
Record with normalization
rec --norm [output.wav]
说明
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.
参数
- -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
FAQ
What is the rec command used for?
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.
How do I run a basic rec example?
Run `rec [output.wav]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -r _rate_ do in rec?
Set sample rate in Hz (e.g., 44100, 48000)