video
video
#
The video file scalar; a loaded Video is the file path.
Media methods (video.metadata(), video.frame_at(t)) read self via
OpenCV, and the intrinsics readers (video.intrinsics(),
video.frame_intrinsics()) read the baked-in lens metadata via PyAV. The heavy
media backends (cv2/PIL/av) are lazy-imported so importing the type system stays cheap.
Video
#
Bases: FileScalar
A video leaf; a loaded Video is its file Path.
Plus the methods below, which read self and extract metadata or
frames via OpenCV.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
frame_at(t=0.0)
#
Extract the frame nearest t seconds as a PIL image (approximate).
Seeks by t × average fps, which drifts on variable-frame-rate clips —
fine for thumbnails; use frame_at_index for exact per-frame reads.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
frame_at_index(index)
#
Decode the index-th video frame as a PIL image — exact under VFR.
Frames are counted in presentation order via PyAV rather than estimated
from an average fps, so this is the reader for contracts that pair the
i-th frame with external per-frame records (PosedVideo's pose and
depth sidecars). For a cheap approximate seek (thumbnails), use
frame_at.
Raises:
| Type | Description |
|---|---|
IndexError
|
If |
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
frame_intrinsics()
#
Per-frame (time_seconds, intrinsics) from the timed metadata track.
One entry per video frame the recorder tagged, in presentation order — the true
focal length and principal point at every frame, not just the whole-clip
average from intrinsics. Empty when the movie carries no per-frame track.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
intrinsics()
#
The whole-clip camera intrinsics baked into the movie, or None if absent.
The recorder's asset-level snapshot: one representative reading for the clip.
For the reading at each frame, use frame_intrinsics. Spec:
docs/dsl/movie-metadata-format.md.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
kind()
#
This video's format: 'mov', 'mp4', or 'unknown'.
metadata()
#
Read width, height, fps, frame_count, and duration via OpenCV.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
thumbnail(max_axis=256, t=0.0)
#
A PIL thumbnail of the frame at t seconds.
Resized so its largest dimension is max_axis.
Source code in capturegraph-lib/capturegraph/types/scalars/imaging/video.py
tooltip(max_axis=64, t=0.0)
#
A base64 PNG data URL for the frame at t seconds (Altair/Vega tooltips).
Resized so its largest dimension is max_axis.