Repository navigation
Move ffmpeg encoding into an es-convert crate - #16
Merged
Merged
Conversation
Presets, the ffmpeg command, encoding and the delay offset move out of es-engine so the USB exporter can encode without the library engine. Adds encode(source, target, preset) for writing anywhere and matches_format for a same-format check. The header reader (inspect) moves with them. No behaviour change; es-engine re-exports both.
There was a problem hiding this comment.
🟡 Changes recommended
The MP4 inspection labels missing or unsupported non-ALAC codecs as AAC, causing the predicate to match files that still need conversion.
1 open issue
What changed in this PR
Extracts format-level audio conversion into es-convert, allowing the USB exporter to use ffmpeg without depending on the library engine.
Changes:
- Moves encoding, presets, delay calculation, header inspection, and their tests into the new crate.
- Adds explicit-target
encodeand quality-independentmatches_formathelpers. - Keeps library conversion orchestration in
es-engine, with re-exports for existing callers.
| File | Description |
|---|---|
native/crates/es-engine/src/lib.rs |
Re-exports inspection and adapts conversion errors. |
native/crates/es-engine/src/convert.rs |
Re-exports encoding helpers while retaining library orchestration. |
native/crates/es-engine/Cargo.toml |
Replaces the direct audio dependency with es-convert. |
native/crates/es-convert/src/lib.rs |
Houses conversion helpers and adds encoding and format-matching tests. |
native/crates/es-convert/src/inspect.rs |
Relocates header inspection and its tests. |
native/crates/es-convert/Cargo.toml |
Defines the new crate and dependencies. |
native/Cargo.toml |
Registers the workspace dependency. |
native/Cargo.lock |
Records the new crate and dependency changes. |
Review effort: Balanced
added 2 commits
October 27, 2026 19:55
An MP4 whose sample entry isn't mp4a or alac (or wasn't found) read as AAC, so the format check would treat it as already AAC. It now reads as MP4 with an unknown encoding, which the compatibility check names as an unknown codec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Part 3 of the "convert audio on USB export" series. Stacked on #15 (base branch
library-convert-waveforms).The USB exporter (
es-usb) will need to encode with ffmpeg, but it shouldn't depend on the whole library engine. This moves the format-only parts ofes-engine::convertinto a newes-convertcrate:Preset,clean_preset,build_command,ffmpeg_path,output_path,convert_file,delay_offset_ms— moved as-is.encode(source, target, preset)— new: encode to any path (partial file + rename, cleaned up on failure).convert_filenow uses it.matches_format(path, preset)— new: whether a file is already in the preset's format, whatever its quality (WAV/AIFF holding compressed audio doesn't count). Used by the USB export's "convert tracks not already in this format".inspect(the container header reader) moves with them, sincematches_formatneeds it.es-enginekeeps the library-specific part (Mode,convert_tracks) and re-exports the moved items andinspect, so callers (es-node, tests) are unchanged.es-engineno longer depends onrb-audiodirectly.No behaviour change. Tests moved with the code; new tests for
matches_formatandencodewriting only the target.