All examples
Media

Audio and video on a shared timeline

Route typed events from one demux session and preserve audio/video PTS offsets.

media_sync.aner
// Supply recording.mkv in the working directory. No camera or microphone opens.
// Check-only example unless that input exists; requires installed FFmpeg.
import aner.audio
import aner.video
import aner.media

let session = media.open("recording.mkv", normalize_pts: true)
let block = audio.block_slot()
let frame = video.frame_slot()
var status = session.read_into(block, frame)
while status == "audio" || status == "video" || status == "timeout" {
    if status == "audio" {
        let anchor = block.freeze()
        print(anchor.time())
        print(anchor.timeline(anchor.first_sample() / anchor.rate()))
    }
    if status == "video" {
        print(frame.pts_ns())
        let retained = media.freeze_video(frame)
        print(retained.width())
    }
    status = session.read_into(block, frame)
}
if status == "failed" {
    print(session.error())
}
session.close()

Make it your experiment.

Use Aner 0.1.0 or newer. Save this program as examples/media/media_sync.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/media/media_sync.aner
aner run examples/media/media_sync.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires Aner 0.1.0 or newer. Native PCM/WAV, synthesis, FFT and speech activity are available independently of optional FFmpeg and model backends. Decoding, resampling or local transcription requires the corresponding capability and separately supplied inputs or weights.

Credential setup
aner check examples/media/media_sync.aner
aner run examples/media/media_sync.aner

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner