#decoding #high #high-speed #ffmpeg #quality #pcm

bin+lib hodges

A small library for high speed, high quality pcm audio decoding

2 releases (1 stable)

1.0.0 Jul 24, 2019
0.1.0 Feb 14, 2019

#423 in Video

27 downloads per month
Used in 2 crates

GPL-3.0-or-later

37KB
723 lines

hodges

Hodges is a small rust library build around libav that aims to provide high quality, high speed audio transcoding to "raw" f32le PCE audio. It is designed to be statically linked (with the exception of libAV components), in order to avoid system calls when using ffmpeg to transcode audio.

It's named after Johnny Hodges, an alto sax player well known for playing with Duke Ellington's big band.

Future improvements

Hodges is currently quite slow at decoding flac and alac files (2x-5x slower than ffmpeg), for reasons that are not entirely clear. It may be due to a lack of parallelism in the core decoding "loop".

Hodges currently dynamically links the various components of libav that it relies on, and assumes that the user/developer already has libav/ffmpeg installed at build time. At some point it would be good to manually build libav/ffmpeg so that it can be statically linked, or so that hodges can be cross compiled for other platforms.


lib.rs:

A rusty interface to libffmpeg for fast(ish) audio decoding.

libhodges provides a simple to use interface for decoding audio files to single channel 44100hz 32-bit little endian PCM data. In effect, it's static bindings to ffmpeg that allow us to achieve the equivalent of this one-line ffmpeg call:

ffmpeg -loglevel quiet -i <filename> -f f32le -acodec pcm_f32le -ac 1 -ar 44100 pipe:1

Using libhodges, however, means that the user doesn't have to worry about subprocesses, streams, or other fun operating system rubbish - instead, they get access to the ffmpeg internals. The one line command line call can instead replaced with the following:

let state: State<u8> =
    State::from_file(filename.clone())?;
for c in state {
    io::stdout().write(&[c])?;
}
io::stdout().flush()?;

Naming

Hodges is part of the Ellington project - a set of tools designed to make it easier for swing dance DJ's to automatically calculate the tempo of swing music. Each component of the project is named after a member of (or arranger for) Duke Ellington's band. Hodges is named after Johnny Hodges, the lead alto sax player of Ellington's band, and one of the most skillful and talented alto sax players of the swing era.

Dependencies

~0–2.5MB
~48K SLoC