mp3dec, mp3enc, oggdec, oggenc, flacdec, sundec, wavdec, pcmconv, mixfs – decode and encode audio files


audio/mp3dec [ -s seconds ] [ -d ]
audio/oggdec [ -s seconds ]
audio/flacdec [ -s seconds ]

audio/mp3enc [ -hprv ] [ -b bitrate ] [ -B bitrate ] [ -m mode ] [ -q q ] [ -s sfreq ] [ -V q ] [ long or silly options ]

audio/pcmconv [ -i fmt ] [ -o fmt ] [ -l length ]

audio/mixfs [ -D ] [ -s srvname ] [ -m mtpt ]


These programs decode and encode various audio formats from and to 16-bit stereo PCM (little endian). The decoders read the compressed audio data from standard input and produce PCM on standard output at a sampling frequency of 44.1KHz.

Mp3dec decodes MPEG audio (layer 1, 2 and 3). The -d option enables debug output to standard error. Oggdec, flacdec, sunwdec and wavdec are like mp3dec but decode OGG Vorbis, FLAC lossless audio, Sun audio and RIFF wave.

Decoding options

-s seconds

seek to a specific position in seconds before decoding.  

The encoders read PCM on standard input and produce compressed audio on standard output.

Oggenc and mp3enc produce OGG Vorbis and MP3 audio. For mp3enc, the MP3 file will use ‘constant bit-rate’ (CBR) encoding by default, but that can be changed via --abr (average bitrate desired, ABR) or -v (variable bitrate, VBR).

Oggenc accepts raw PCM in the same byte order as /dev/audio (little-endian), t mp3enc -r expects big-endian.

Encoding options


set minimum allowed bitrate in Kb/s for VBR, default 32Kb/s. For CBR, set the exact bitrate in Kb/s, which defaults to 128Kb/s.  


set maximum allowed bitrate in Kb/s for VBR, default 256Kb/s.  


same as -q 2 .  


mode may be (s)tereo, (j)oint, (f)orce or (m)ono (default j). force forces mid/side stereo on all frames.  


add CRC error protection (adds an additional 16 bits per frame to the stream). This seems to break playback.  


sets output quality to q (see -V).  


input is raw pcm  


set sampling frequency of input file (in KHz) to sfreq, default is 44.1.  


use variable bitrate (VBR) encoding  


set quality setting for VBR to q. Default q is 4; 0 produces highest-quality and largest files, and 9 produces lowest-quality and smallest files.  

Long options

--abr bitrate

sets average bitrate desired in Kb/s, instead of setting quality, and generates ABR encoding.  

--resample sfreq

set sampling frequency of output file (in KHz) to sfreq, default is input sfreq.  

--mp3input input

is an MP3 file  

Silly options


same as -q 7 . Such a deal.  


mark as non-original (i.e. do not set the original bit)  


mark as copyright  


disable sfb=21 cutoff  

-e emp

de-emphasis n/5/c (default n)  


allow channels to have different blocktypes  


disable Xing VBR informational tag  


autoconvert from stereo to mono file for mono encoding  


force byte-swapping of input (see dd(1) instead)  


don’t print progress report, VBR histograms  


only use the ATH for masking  


disable VBR histogram display  


experimental voice mode  

Pcmconv is a helper program used to convert various PCM sample formats. The -i and -o options specify the input and output format fmt of the conversion. Fmt is a concatenated string of the following parts:


sample format is little-endian signed integer where # specifies the number of bits  


unsigned little-endian integer format  


singed big-endian integer format  


unsigned big-endian integer format  


floating point format where # has to be 32 or 64 for single- or double-precision  


8-bit a-law format  


8-bit µ-law format  


specifies the number of channels  


gives the samplerate in Hz  

The program reads samples from standard input converting the data and writes the result to standard output until it reached end of file or, if -l was given, a number of length bytes have been consumed from input.

Mixfs is a fileserver serving a single audio file which allows simultaneous playback of audio streams. When run, it binds over /dev/audio and mixes the audio samples that are written to it. A service name srvname can be given with the -s option which gets posted to /srv. By default, mixfs mounts itself on /mnt/mix and then binds /mnt/mix/audio over /dev. A alternative mountpoint mtpt can be specified with the -m option. The -D option causes 9p debug messages to be written to file-descriptor 2.


Play back an .mp3


audio/mp3dec <foo.mp3 >/dev/audio

Encode a .wav file as highest-quality MP3.


audio/mp3enc -q 0 -b 320 <foo.wav >foo.mp3

Create a fixed 128Kb/s MP3 file from a .wav file.


audio/mp3enc -h <foo.wav >foo.mp3

Streaming from stereo 44.1KHz raw PCM data, encoding mono at 16KHz (you may not need dd):


dd -conv swab | audio/mp3enc -a -r -m m --resample 16 -b 24




play(1), juke(7), playlistfs(7)


Pcmconv first appeared in 9front (December, 2012). Mixfs first appeared in 9front (December, 2013).