7 Encoder Test Program
| (require racket-audio/encoder-test) | package: racket-audio |
The racket-audio/encoder-test module is a small integration test and command-line wrapper around racket-audio/audio-encoder. It is useful for checking that the native encoder libraries are available and that a concrete source file can be transcoded to Opus or FLAC.
The module depends on "tests.rkt" for its default input file. For portable tests, pass an explicit input file.
7.1 Program use
Run the test module directly to encode the default test file to a temporary Opus file:
racket encoder-test.rkt |
Useful command-line examples:
racket encoder-test.rkt --encoder opus --input input.flac --output output.opus --bitrate-kbps 224 |
|
racket encoder-test.rkt --encoder flac --input input-96k.flac --output output-48k.flac --sample-rate 48000 --bits-per-sample 24 --compression-level 8 |
The program prints the selected encoder, settings, percentage progress, and a summary of the result hash returned by audio-encode. Progress is based on input frames read from the decoder.
7.2 Program options
The command-line wrapper accepts these options:
-e, –encoder: opus or flac.
-i, –input: input audio file.
-o, –output: output audio file.
–sample-rate: target sample rate or source.
–bits-per-sample: target FLAC bit depth or source.
–bitrate-kbps: Opus bitrate in kbit/s.
–compression-level: FLAC compression level.
–no-tags: disable copying tags and embedded pictures.
7.3 Racket functions
procedure
(encoder-test input-file output-file encoder settings [ #:copy-tags? copy-tags?]) → hash? input-file : path-string? output-file : (or/c path-string? #f) encoder : (or/c symbol? string?) settings : hash? copy-tags? : boolean? = #t
procedure
(encoder-test-opus input-file [ output-file #:bitrate-kbps bitrate-kbps #:sample-rate sample-rate #:copy-tags? copy-tags?]) → hash? input-file : path-string? output-file : (or/c path-string? #f) = #f bitrate-kbps : exact-positive-integer? = 160 sample-rate : (or/c exact-positive-integer? 'source) = 'source copy-tags? : boolean? = #t
The sample-rate argument is normally 'source. Opus encoding passes the input rate to libopusenc; libopusenc performs the internal resampling required for Opus output.
procedure
(encoder-test-flac input-file [ output-file #:compression-level compression-level #:sample-rate sample-rate #:bits-per-sample bits-per-sample #:copy-tags? copy-tags?]) → hash? input-file : path-string? output-file : (or/c path-string? #f) = #f compression-level : exact-nonnegative-integer? = 8 sample-rate : (or/c exact-positive-integer? 'source) = 'source
bits-per-sample : (or/c exact-positive-integer? 'source) = 'source copy-tags? : boolean? = #t