audio_processor
A modular audio processing crate for Rust that leverages FFmpeg to perform a wide range of audio operations. The crate is designed for ease of integration and reuse in various projects. It provides a set of functions for audio editing—such as trimming, seeking, transcoding, applying effects, merging, reversing, normalizing, and overlaying audio.
Features
-
File I/O & Metadata
- Load audio files.
- Save processed audio files.
-
Basic Editing Operations
- Seek: Jump to a specified time position.
- Trim: Extract a segment from an audio file.
- Merge: Concatenate multiple audio files using FFmpeg's concat demuxer.
-
Transcoding
- Convert audio files between formats (e.g., WAV, MP3, FLAC, OGG).
-
Audio Effects & Processing
- Volume Adjustment: Scale the audio volume.
- Speed Change: Modify playback speed.
- Effects: Apply fade-in, fade-out, echo, and more.
- Reverse: Reverse the audio stream.
- Normalize: Adjust audio volume to a standard level.
- Overlay: Mix one audio file onto another starting at a specified time.
-
Integration Tests
- Comprehensive tests to ensure each feature works as expected (requires FFmpeg to be installed).
Prerequisites
- Rust: Ensure you have Rust installed. You can install it from rustup.rs.
- FFmpeg: This crate requires the FFmpeg executable. Install FFmpeg and ensure it is available in your system's PATH.
- Tempfile Crate: Used for managing temporary files (configured via Cargo.toml).
Installation
Add the following dependency in your Cargo.toml file:
[]
= "0.0.1"
If you are developing or testing locally, clone the repository and build using:
Usage
Here’s an example demonstrating how to use the crate:
use Duration;
use ;
Running Integration Tests
The repository includes integration tests to validate each feature. The tests automatically generate a 5‑second silent audio file (using FFmpeg) if one is not present. To run the tests, execute:
Make sure that FFmpeg is installed and accessible in your PATH.
Project Structure
audio_processor/
├── Cargo.toml # Package metadata and dependencies.
├── src
│ ├── lib.rs # Core library exposing the public API.
│ ├── io.rs # Audio file input/output functions.
│ ├── processing.rs # Audio processing functions and effects.
│ ├── transcoding.rs # Audio format definitions and transcoding functions.
│ └── errors.rs # Custom error definitions.
└── tests
└── integration_tests.rs # Integration tests covering all features.
Contributing
Contributions are welcome! If you have ideas for new features, bug fixes, or improvements, please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Acknowledgements
- FFmpeg for the robust command-line tool used for audio processing.
- The Rust community for providing great tooling and libraries to build upon.