Expand description
Media Packager Library
A trait-based library for fragmenting and packaging multi-resolution MP4 files into DASH/HLS formats using FFmpeg and Bento4.
§Features
- Parallel demuxing with FFmpeg
- Parallel fragmentation with Bento4 (mp4fragment)
- DASH/HLS packaging with Bento4 (mp4dash)
- Configurable naming templates
- Automatic temporary file management
- One-time runtime binary checks with helpful error messages
- Comprehensive tracing and logging
§Example
use std::path::PathBuf;
use s4m_media_packager::{LogConfig, MediaPipeline, MediaPipelineConfig, init_tracing};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize tracing
init_tracing(LogConfig::development())?;
let pipeline = MediaPipeline::new()?;
let inputs = vec![
PathBuf::from("video_270p.mp4"),
PathBuf::from("video_720p.mp4"),
];
let config = MediaPipelineConfig::default();
let output_dir = PathBuf::from("./output");
let result = pipeline.execute(inputs, config, output_dir).await?;
println!("Packaged to: {:?}", result.output_dir);
Ok(())
}Re-exports§
pub use error::MediaPackagerError;pub use error::Result;
Modules§
Macros§
- log_
progress - Macro to log progress with percentage
- log_
stage_ duration - Macro to log stage timing
Structs§
- LogConfig
- Logging configuration options
- Media
Pipeline - High-level media packaging pipeline
- Media
Pipeline Config - Complete pipeline configuration
- Package
Result - Result of complete packaging pipeline
Functions§
- init_
tracing - Initialize the tracing subscriber with the given configuration
- init_
tracing_ from_ env - Initialize tracing from RUST_LOG environment variable