Expand description
Generate machine-readable A/V sync test videos and measure audio/video drift.
Every video frame of a generated file carries its frame number three ways: a 48-bit barcode strip (with a CRC), a QR code, and a seven-segment timecode for people. Every frame’s worth of audio carries the same number (mod 65536) as four simultaneous tones. Analysis decodes both sides of a captured or re-encoded copy and reports, frame by frame, how far the audio has drifted from the video. Precision is a small fraction of a millisecond.
use av_drift_detector::{AnalyzeOptions, GenerateOptions, analyze, generate};
let fps = "29.97".parse()?;
generate(&GenerateOptions::new("sync.mp4", fps, 10.0), |_| {})?;
// ... play `sync.mp4` through the system under test and record it ...
let report = analyze("captured.mp4".as_ref(), &AnalyzeOptions::default())?;
println!("{}", report.summary_text());The pattern rendering (pattern), audio code (audio) and the analysis
itself (analyze::analyze_scan) are plain Rust. Only file input and output
need FFmpeg: linked, with the ffmpeg feature (on by default), or run as the
ffmpeg and ffprobe programs, with the ffmpeg-cli feature. Without
either, the crate builds for targets such as Android and WebAssembly.
Re-exports§
pub use analyze::AnalyzeOptions;pub use analyze::analyze;pub use media::encode::generate;pub use media::AudioCodec;pub use media::GenerateOptions;pub use media::Progress;pub use media::VideoCodec;pub use report::CaptureMode;pub use report::DriftReport;pub use report::DriftSummary;pub use report::FrameDrift;pub use report::FrameStatus;pub use timing::FrameRate;pub use timing::parse_time;
Modules§
- analyze
- Matching decoded video frames against decoded audio cells.
- audio
- The audio side of the test pattern: a 16-bit frame id carried by tones.
- media
- Captures as the analyser sees them, test-file settings, and FFmpeg input
and output: linked through
ffmpeg-next(theffmpegfeature, modulesdecodeandencode), or by running theffmpegandffprobeprograms (theffmpeg-clifeature, moduleffmpeg_cli). - pattern
- The visual side of the test pattern: rendering frames and reading stamps back.
- report
- Drift reports and their text, JSON and CSV renderings.
- timing
- Exact frame-rate arithmetic and time parsing.
Enums§
- Error
- Errors returned by av-drift-detector.