// 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()
