Pipe Ecasound Audio Output to Stdout
Ecasound is a powerful multitrack audio processing tool that can route real-time audio streams directly through Unix pipelines. This article explains how Ecasound directs its processed audio stream to standard output (stdout), how to define audio formats for piping, and how to chain Ecasound cleanly with other command-line utilities like FFmpeg or LAME.
Directing Output to Stdout
Ecasound handles audio targets through the -o option. To
send the output buffer directly to the terminal's standard output
instead of saving it to a file or sending it to an ALSA/JACK device,
specify stdout as the output target.
A basic command to stream an audio file to stdout looks like this:
ecasound -i input.wav -o stdoutBy default, Ecasound writes diagnostic, status, and processing
messages to standard error (stderr). This architectural
separation ensures that binary audio data passing through
stdout remains uncorrupted by textual terminal logs.
Specifying Output Formats
Downstream programs typically need to know the audio format, sample
rate, bit depth, and channel count. You can define this explicitly using
Ecasound's format parameters or by using standard extension hints with
stdout.
To pipe a formatted RIFF/WAV stream including header data, append the
.wav extension to the stdout target:
ecasound -i input.flac -o stdout.wavFor headerless, raw PCM data, specify the format string with the
-f flag:
ecasound -i input.wav -f:s16_le,2,44100 -o stdoutIn this example, -f:s16_le,2,44100 configures the stream
as signed 16-bit little-endian samples, 2 channels (stereo), at a 44,100
Hz sample rate.
Chaining with Downstream Tools
Once Ecasound is set to stream to stdout, use the
standard shell pipe operator (|) to pass the data to
another application's standard input.
Example: Encoding to MP3 with LAME
To process an audio file with Ecasound effects and compress it on the fly with LAME:
ecasound -i input.wav -ea:150 -o stdout.wav | lame - output.mp3Example: Playing via Aplay
To send raw PCM audio to ALSA's aplay utility:
ecasound -i input.mp3 -f:s16_le,2,48000 -o stdout | aplay -t raw -f cd -r 48000Example: Suppressing Console Messages
To prevent Ecasound from printing runtime text and notifications to
stderr, use the quiet flag (-q):
ecasound -q -i input.wav -o stdout.wav | ffmpeg -i - -c:a aac output.m4a