Video API Reference¶
Signals¶
VideoEnsemble¶
VideoEnsemble
¶
Bases: BaseSignal
Ensemble of video deepfake detection signals. Combines RPPG, I3D, and LipSync using weighted fusion.
Example
from veridex.video import VideoEnsemble ensemble = VideoEnsemble() result = ensemble.run("video.mp4") print(f"Combined score: {result.score:.2f}")
Source code in veridex/video/ensemble.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 | |
__init__(signals=None)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signals
|
Optional[List[BaseSignal]]
|
List of signals to ensemble. Defaults to all three video signals. |
None
|
Source code in veridex/video/ensemble.py
check_dependencies()
¶
run(input_data)
¶
Run all signals and fuse results using weighted average.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str
|
Path to video file |
required |
Returns:
| Type | Description |
|---|---|
DetectionResult
|
DetectionResult with fused score and metadata from all signals |
Source code in veridex/video/ensemble.py
RPPGSignal¶
RPPGSignal
¶
Bases: BaseSignal
Detects Deepfakes by analyzing the rPPG (Remote Photoplethysmography) signal. Real humans have a heartbeat (0.7-4Hz). Deepfakes often lack this or have noise.
Source code in veridex/video/rppg.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
run(input_data)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
str
|
Path to video file. |
required |
Source code in veridex/video/rppg.py
I3DSignal¶
I3DSignal
¶
Bases: BaseSignal
Detects Deepfakes using Spatiotemporal features (I3D).
Source code in veridex/video/i3d.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 | |
LipSyncSignal¶
LipSyncSignal
¶
Bases: BaseSignal
Detects Deepfakes by checking Audio-Visual Synchronization (Lip-Sync). Uses SyncNet logic.
Source code in veridex/video/lipsync.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
Utilities¶
FaceDetector¶
FaceDetector
¶
Multi-backend face detector with automatic fallback.
Backends (in order of accuracy): 1. MediaPipe (best, requires mediapipe package) 2. Haar Cascades (fast, less accurate)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
FaceBackend
|
'auto' (try MediaPipe then Haar), 'mediapipe', or 'haar' |
'auto'
|
Source code in veridex/video/processing.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
detect(frame)
¶
Detect faces in a frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
RGB or BGR numpy array (OpenCV uses BGR). |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[int, int, int, int]]
|
List of (x, y, w, h) tuples. |
Source code in veridex/video/processing.py
extract_face(frame, bbox, size=(128, 128))
¶
Extract and resize the face ROI.
Source code in veridex/video/processing.py
track_faces(frames, size=(128, 128))
¶
Track and extract a single face across a sequence of frames. Uses simple IoU tracking and 'largest face' initialization.
Source code in veridex/video/processing.py
Weight Configuration¶
get_weight_config(model_name)
¶
Get weight configuration for a model.
Checks environment variables first, then falls back to defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
One of 'physnet', 'i3d', 'syncnet' |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with 'url', 'filename', 'sha256' |
Example
config = get_weight_config('physnet') print(config['url'])
Source code in veridex/video/weights.py
set_weight_url(model_name, url, sha256=None)
¶
Programmatically override weight URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
One of 'physnet', 'i3d', 'syncnet' |
required |
url
|
str
|
New URL to use |
required |
sha256
|
Optional[str]
|
Optional SHA256 checksum |
None
|
Example
from veridex.video.weights import set_weight_url set_weight_url('physnet', 'https://my-server.com/physnet.pth')
Source code in veridex/video/weights.py
Video Processing Utilities¶
chunk_video_frames(frames, chunk_size, overlap=0)
¶
Yield chunks of video frames for processing long videos.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
ndarray
|
(T, H, W, C) array |
required |
chunk_size
|
int
|
Frames per chunk |
required |
overlap
|
int
|
Overlapping frames between chunks |
0
|
Yields:
| Type | Description |
|---|---|
Tuple[int, ndarray]
|
(start_idx, chunk_frames) |
Example
frames = np.zeros((1000, 224, 224, 3)) for start, chunk in chunk_video_frames(frames, 300, overlap=30): ... # Process chunk of 300 frames ... result = process(chunk)
Source code in veridex/video/utils.py
smart_sample_frames(total_frames, target_frames, strategy='uniform')
¶
Sample frame indices intelligently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_frames
|
int
|
Total available frames |
required |
target_frames
|
int
|
Desired number of frames |
required |
strategy
|
Literal['uniform', 'random']
|
'uniform' (evenly spaced) or 'random' |
'uniform'
|
Returns:
| Type | Description |
|---|---|
List[int]
|
List of frame indices to sample |
Example
indices = smart_sample_frames(300, 64, 'uniform') len(indices) 64
Source code in veridex/video/utils.py
validate_video_file(file_path)
¶
Validate video file and extract metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to video file |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, str, dict]
|
(is_valid, error_message, metadata_dict) |
Example
valid, error, meta = validate_video_file('video.mp4') if valid: ... print(f"FPS: {meta['fps']}, Frames: {meta['total_frames']}")