av-drift-detector (Python)
Measure audio/video sync to a fraction of a millisecond, frame by frame.
Python bindings to av-drift-detector, the Rust library behind the av-drift command. Generate a test video whose every frame, and every frame's worth of audio, carries its own frame number. Play it through whatever you want to test (an encoder, a streaming pipeline, a TV, a video call), record the result, and measure how far the sound has drifted from the picture at every frame.
import av_drift_detector as avd
avd.generate("sync.mp4", fps="29.97", duration=10, audio_offset=0.040)
# ... play sync.mp4 through the system under test and record it as captured.mp4 ...
report = avd.analyze("captured.mp4")
print(report["summary"]["mean_ms"]) # positive means the audio is late
Install
pip install av-drift-detector
Python 3.11 or later. Wheels cover macOS (Apple silicon and Intel), Linux (x64 and arm64, manylinux) and Windows (x64); elsewhere pip builds from source, which needs Rust.
Reading and writing files runs the ffmpeg and ffprobe programs, so install FFmpeg 5.1 or later (brew install ffmpeg, sudo apt install ffmpeg, winget install Gyan.FFmpeg) and keep them on your PATH, or set AV_DRIFT_FFMPEG and AV_DRIFT_FFPROBE to their paths. Writing H.264 needs an FFmpeg with libx264, as those packages have. The in-memory functions below don't need FFmpeg.
Files
generate(output, *, fps="30", duration=10.0, width=1280, height=720, sample_rate=48000, video_codec="h264", audio_codec="aac", audio_offset=0.0, on_progress=None)writes a test video and returns a summary.audio_offset(seconds) deliberately delays the audio; negative makes it early.on_progress(frames_done, frames_total)is called about once a percent. FFV1 video and PCM audio need.movor.mkv.analyze(path, *, offset=0.0, duration=None, fps=None, use_qr=True, capture="auto")measures every frame of a capture.offsetanddurationchoose a window in seconds, andcaptureis"auto","file"(a digital copy) or"camera"(a phone filming a screen).
Reports are the dicts av-drift analyze --json writes (format), typed as DriftReport, so json.dump(report, f) saves the CLI's format:
s = report["summary"]
print(f"{s['mean_ms']:+.2f} ms ± {s['stddev_ms']:.2f}, skew {s['skew_ppm']:+.1f} ppm")
for f in report["frames"]:
if f["status"] == "ok":
print(f["time"], f["video_frame"], f["drift_ms"])
Frames and audio from elsewhere
If you already have decoded frames and audio (a capture card, WebRTC, a camera), measure them without files:
frames = []
for time, luma in my_frames(): # 8-bit luma (Y) planes: bytes, numpy uint8, ...
frames.append({"time": time, "stamp": avd.read_frame(luma, width, height)})
audio = {"sample_rate": 48_000, "start_time": t0, "samples": mono_float32} # array("f"), numpy float32, ...
report = avd.analyze_frames(frames, audio, width=width, height=height)
Frame times and start_time must be on the same clock, in seconds.
read_frame(luma, width, height, stride=None, *, try_qr=True)reads a frame's stamp (barcode, then QR code), or returns None.PatternRenderer(*, fps="30", width=1280, height=720, sample_rate=48000).render(frame_id)draws a test-pattern frame as luma bytes.synthesize_audio(count, *, fps="30", sample_rate=48000, delay=0.0, start=0)makes the test audio as anarray("f").
Errors raise AvDriftError. Slow calls release the GIL, so they run in parallel from threads.
More
The repository has the guides: measuring with a camera, the test pattern specification, and how the analysis works. MIT licensed.
Metadata
Release files for av-drift-detector 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| av_drift_detector-0.2.1.tar.gz | 82.0 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| av_drift_detector-0.2.1-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| av_drift_detector-0.2.1-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| av_drift_detector-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 4.7 MB
Release files / av_drift_detector-0.2.1.tar.gz
| Download URL | av_drift_detector-0.2.1.tar.gz |
|---|---|
| Size | 82.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a671e82aebe926fba79173414eb1dc3ce298b12b60d39d7009820493c18a350
|
|
BLAKE2b-256 checksum How to use checksums |
d9a28d191077a79e077ee1f4b5dc072cc8d786f5500388e2699458f6d51094bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / av_drift_detector-0.2.1-cp311-abi3-win_amd64.whl
| Download URL | av_drift_detector-0.2.1-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 873.3 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e58e1358b69134ad01b88b6df354c0e3f0d32f58ff8881e33d51b1cff17439c7
|
|
BLAKE2b-256 checksum How to use checksums |
19d118b8a1a33b96920488d5bedc8eb31f45b0d7d8a61e8ce1b5659e50a67e2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7c10d957956615ea60dac8bbb750db7eac3004181b920772c747c9640ca88788
|
|
BLAKE2b-256 checksum How to use checksums |
853f3ae36c43c1a0308bce5969fac07250a643ba81ab37c2b4157d681888cb93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | av_drift_detector-0.2.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 902.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
168433fdae46a89eefd3279f050a1b5ecccb73ebb2f989d4e815fafbc092574a
|
|
BLAKE2b-256 checksum How to use checksums |
e49730f887c91ffc2dfe9fbc39b2ea97f7f1da3fae92c4499a40aceb6763a260
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / av_drift_detector-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | av_drift_detector-0.2.1-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 826.0 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3f8c20504bb2998616a18fd69ad05453492911f6e235a1ed50f5ab7c34919818
|
|
BLAKE2b-256 checksum How to use checksums |
53eece783911286c1004d9813f85b444378a889f0138d02b159151cf09eeead2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / av_drift_detector-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | av_drift_detector-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 973.0 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d8e7f437510eb5bf2cd3e54f6eac53f58b1dc5c82c75ee6abb3962dbbbacf60a
|
|
BLAKE2b-256 checksum How to use checksums |
d2f5a33aa45de54c266ac42d6ee05a3e7aa56343da4ff477fdf5a7f0b7274693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for av-drift-detector 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for av_drift_detector-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.