Is there an application capable of recording sound that I can run from the command line on XP?
Ideally I'd start it with one command and stop it with another. Or I could specify a duration with the starting command.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
To record sound using command line on Windows you can use fmedia:
fmedia --record --out=Recording.wav
You can stop recording at any time by pressing
While recording, fmedia shows how loud the signal is, for example:
g:\fmedia>fmedia --record --out=myrec.flac fmedia v0.10 0:19 [========..] -7.89dB / -1.31dB
Supported formats are WAV, FLAC, OGG and MP3. Output to WAV is the fastest. However, FLAC compression is quite fast too, so you probably won't notice any difference in CPU usage.
If you want to capture sound from a specific device (not just the default one):
Step 1. Use
--list-dev switch to show all available devices.
Step 2. Pick a device you want to use and call fmedia with
For example, start recording from a specific device - Microphone:
C:\>fmedia --list-dev fmedia v0.10 Playback: device #1: Realtek Digital Output (Realtek High Definition Audio) device #2: Speakers (Realtek High Definition Audio) Capture: device #1: Stereo Mix (Realtek High Definition Audio) device #2: Microphone (Realtek High Definition Audio) device #3: Line In (Realtek High Definition Audio) C:\>fmedia --record --out=Recording.wav --dev-capture=2
FFmpeg, besides conversion can do a lot more, Device I/O is our main focus.
Input devices are specific to host systems, for Windows FFmpeg uses DirectShow API for capturing both audio and video. The following retrieves a listing of available input devices visible to dshow.
ffmpeg -list_devices true -f dshow -i null
-sources following device name is used for listing input streams but for dshow it is quite weird, I don't know why.
The following captures 30 seconds of audio and saves it as a FLAC file,
DEVICE_NAME is a placeholder for the name of the device reported by DirectShow.
ffmpeg -f dshow -t 30 -i "audio=DEVICE_NAME" out.flac
FFmpeg Documentation on dshow.
This is old but might be an alternative
This program encodes live audio from line-in or microphone directly into Ogg Vorbis, MP3, FLAC, Speex and other formats.
The current version only has built-in support for Ogg Vorbis and Speex. It means you can use any other encoders too, but for encoders other than Ogg Vorbis and Speex you'll need to manually specify the command-line.