Analyze a video file
1from lynx import LYNX2 3model = LYNX("lynx-basic")4 5for results in model.stream("clip.mp4"): # video file path6# for results in model.stream(0): # default webcam (integer index)7 for box, label in zip(results.boxes.xyxy, results.labels):8 print(f"{label} at {box}")model.stream(...) is a generator — it yields one Results per frame and holds only one frame's worth of memory at a time. A 4-hour 30fps video is 432K frames; eager batching would OOM. Streaming lets you iterate linearly through arbitrarily long inputs.
Use it for: post-processing recorded clips, batch backfill jobs, surveillance review, anything where you process frames left-to-right and don't need random access.
Source is a video file path (string) or a webcam index (integer — 0 for default cam, 1 for the next, etc.). RTSP and multi-camera flows do NOT go here — for those, StreamManager handles reconnect logic + parallel pipelines. Don't try to loop model.stream(rtsp_url); it'll fight you when the stream drops.
For reactive logic ("alert me when a person enters the frame") combine with model.on_detect("person", callback) — the callback fires from inside the generator loop without you writing the conditional.