Artifact extraction
Artifact extraction runs immediately after ingest and before model-free forensics, analysis, and detector selection (verity extract, verity run, and POST /api/extract). Implemented under src/verity/extract/, it converts raw media into normalized intermediate exhibits without making any authenticity claims.
The BaseExtractor & Artifact contract
Every extractor inherits BaseExtractor (src/verity/extract/base_extractor.py), initializes workspace/artifacts/, and implements extract(media_id: str) -> ArtifactCollection. src/verity/models/artifacts.py defines ArtifactType (frame, face_crop, audio_clip, metadata, landmarks, frequency_spectrum), Artifact, and ArtifactCollection.
Extractors distinguish missing prerequisites from absent content: missing ingested media raises FileNotFoundError, whereas benign mismatches (images passed to frame/audio extraction, or silent videos without soundtracks) return an empty ArtifactCollection cleanly.
Shipped extractors in config/pipeline.yaml order
config/pipeline.yaml runs frame, face, metadata, and audio in fixed sequence:
FrameExtractor(frame_extractor.py): Confirms video MIME viafiletypeand stream presence viaffprobe, then extracts PNG frames viaffmpeg -i <media> -vf fps=<fps> -frame_pts 1 frame_%05d.png -y(default 1 fps) underartifacts/<id>/frames/.FaceExtractor(face_extractor.py): Iterates sortedframe_*.pngimages with OpenCV'shaarcascade_frontalface_default.xml(scaleFactor=1.1,minNeighbors=5,minSize=(50, 50)), clamps boxes, rejects< 20x20px boxes, and writesartifacts/<id>/faces/<frame_stem>_face_<i>.pngwith bounding-box params. Because it readsframes/, it naturally depends onFrameExtractorrunning first.MetadataExtractor(metadata_extractor.py): Records file name/size and capturesffprobe -show_format -show_streamsoutput intoartifacts/<id>/metadata/metadata.json, recordingffprobe: nullgracefully ifffprobeis absent.AudioExtractor(audio_extractor.py): Exports normalized 16 kHz mono 16-bit PCM WAV viaffmpeg -vn -acodec pcm_s16le -ar 16000 -ac 1 audio.wav. If no audio stream exists orffmpegfails, returns an emptyArtifactCollectionso audio-dependent detectors are excluded cleanly byDetectorSelectorrather than failing the case. (Note: the model-freeaudioforensic analyzer decodes at native sample rate separately so high-frequency> 8 kHzspectral traces are not erased by 16 kHz resampling.)
Fail-soft API behavior & isolated detector staging
- Fail-soft isolation:
verity_api.service.run_extractwraps each extractor in its owntry/except, logging failures underfailed_extractorsso losing one optional extractor never aborts the entire case. - Staged detector inputs: When
DetectorRunner.runlaunches a detector,_prepare_input_dir(src/verity/detect/detector_runner.py) creates a fresh temporary directory containing a copy of the media file (media/) andartifacts/<id>/(artifacts/). Detectors never hold direct write paths to workspace evidence.
Related pages
- Examination pipeline — full stage order across CLI & API.
- Ingest and media analysis — SHA-256 admission and
ffprobe/Haar scan. - Shared detector engine — how staged audio and frames are consumed.
- Detector runtime and isolation —
DetectorRunnerstaging and cleanup.