Skip to main content

Crate s4m_media_packager

Crate s4m_media_packager 

Source
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§

error

Macros§

log_progress
Macro to log progress with percentage
log_stage_duration
Macro to log stage timing

Structs§

LogConfig
Logging configuration options
MediaPipeline
High-level media packaging pipeline
MediaPipelineConfig
Complete pipeline configuration
PackageResult
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