Skip to content

Move ffmpeg encoding into an es-convert crate - #16

Merged
claw1200 merged 3 commits into
mainfrom
es-convert-crate
Oct 27, 2026
Merged

claw1200 merged 3 commits into
mainfrom
es-convert-crate

Conversation

@claw1200

Copy link
Copy Markdown
Owner

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 of es-engine::convert into a new es-convert crate:

  • 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_file now 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, since matches_format needs it.

es-engine keeps the library-specific part (Mode, convert_tracks) and re-exports the moved items and inspect, so callers (es-node, tests) are unchanged. es-engine no longer depends on rb-audio directly.

No behaviour change. Tests moved with the code; new tests for matches_format and encode writing only the target.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 encode and quality-independent matches_format helpers.
  • 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

Comment thread native/crates/es-convert/src/lib.rs
claw1200 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.
@claw1200
claw1200 changed the base branch from library-convert-waveforms to main October 27, 2026 21:30
@claw1200
claw1200 merged commit 01528df into main Oct 27, 2026
3 checks passed
@claw1200
claw1200 deleted the es-convert-crate branch October 27, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants