mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-08 19:42:12 +00:00
FilmCraft's FLAC encoder behind `flac-encode`, kept over SoundCraft's: linear prediction, stereo decorrelation and the STREAMINFO MD5 give 0.1-37% smaller files on 12 test signals, and the output is bit-exact through `flac` and ffmpeg. It is 3-5x slower than SoundCraft's, still about 56x real time. `lossless-encode` is now `pcm-encode` plus `flac-encode`, and `EncodeFormat::Flac` writes it through `encode` and `FileEncoder`. With only one of the two features, the other's formats are refused as `Unsupported`. The tests that use FLAC files as decode fixtures (truncation, corruption, metadata bounds, zero-frame files, container preflight) come with it, as do the FLAC oracle tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
114 lines
5.2 KiB
YAML
114 lines
5.2 KiB
YAML
name: Shared audio
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"]
|
|
pull_request:
|
|
paths: ["crates/audio/**", "crates/media/**", "crates/media-testkit/**", "Cargo.toml", "Cargo.lock", ".github/workflows/audio.yml"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: shared-audio-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint:
|
|
timeout-minutes: 15
|
|
name: Audio lint, feature sets, docs, WASM
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
targets: wasm32-unknown-unknown
|
|
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
with:
|
|
key: craft-audio-lint
|
|
- run: cargo fmt -p craft-audio --check
|
|
# Each feature on its own, so code that needs another feature fails here.
|
|
- name: Clippy, each feature alone
|
|
run: |
|
|
for f in "" decode decode-native symphonia encode lossless-encode pcm-encode flac-encode peaks serde; do
|
|
echo "::group::features: ${f:-none}"
|
|
cargo clippy -p craft-audio --all-targets --locked --no-default-features ${f:+--features "$f"} -- -D warnings
|
|
echo "::endgroup::"
|
|
done
|
|
- run: cargo clippy -p craft-audio --all-targets --locked --all-features -- -D warnings
|
|
# missing_docs is a warning in the crate; -D warnings makes it (and broken links) fail here.
|
|
- run: cargo doc -p craft-audio --all-features --no-deps --locked
|
|
env:
|
|
RUSTDOCFLAGS: "-D warnings"
|
|
# Partial feature sets must document too (their links to other features are allowed to dangle).
|
|
- run: cargo doc -p craft-audio --no-default-features --features decode-native --no-deps --locked
|
|
env:
|
|
RUSTDOCFLAGS: "-D warnings"
|
|
- run: cargo doc -p craft-audio --no-default-features --features lossless-encode --no-deps --locked
|
|
env:
|
|
RUSTDOCFLAGS: "-D warnings"
|
|
- run: cargo check -p craft-audio --all-features --locked --target wasm32-unknown-unknown
|
|
- run: cargo check -p craft-audio --no-default-features --features lossless-encode --locked --target wasm32-unknown-unknown
|
|
msrv:
|
|
timeout-minutes: 10
|
|
name: Audio on the minimum Rust version
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# The workspace's rust-version.
|
|
- run: rustup toolchain install 1.95.0 --profile minimal
|
|
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
with:
|
|
key: craft-audio-msrv
|
|
- run: cargo +1.95.0 check -p craft-audio -p craft-media --all-features --locked
|
|
features:
|
|
timeout-minutes: 10
|
|
name: Audio tests without symphonia and lossless-encode only
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
|
|
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
with:
|
|
key: craft-audio-features
|
|
- run: cargo test -p craft-audio --no-default-features --features lossless-encode --locked
|
|
- run: cargo test -p craft-audio --no-default-features --features pcm-encode --locked --lib
|
|
- run: cargo test -p craft-audio --no-default-features --features flac-encode --locked --lib
|
|
- run: cargo test -p craft-audio --no-default-features --features decode-native --locked
|
|
test:
|
|
timeout-minutes: 20
|
|
name: Audio tests with ffmpeg oracles
|
|
# Pinned for the ffmpeg its apt ships (8.0): the oracle's files come from this ffmpeg, and
|
|
# ffmpeg 6, on ubuntu-24.04, writes MP2 and E-AC-3 in Matroska with early ends.
|
|
runs-on: ubuntu-26.04
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
|
|
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
with:
|
|
key: craft-audio-test
|
|
- name: Build tests while installing ffmpeg
|
|
run: |
|
|
# The man-db index rebuild after dpkg is slow on hosted runners.
|
|
sudo rm -f /var/lib/man-db/auto-update
|
|
(sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends ffmpeg) > "$RUNNER_TEMP/apt.log" 2>&1 &
|
|
apt=$!
|
|
cargo test -p craft-audio --all-features --locked --no-run
|
|
wait "$apt" || { cat "$RUNNER_TEMP/apt.log"; exit 1; }
|
|
ffmpeg -hide_banner -version | sed -n 1p
|
|
- run: cargo test -p craft-audio --all-features --locked
|
|
env:
|
|
CRAFT_MEDIA_REQUIRE_ORACLES: "1"
|
|
CRAFT_MEDIA_FIXTURES_DIR: ${{ runner.temp }}/media-fixtures
|