{"record":{"id":"145926788f1501c4","repo":"screenpipe/screenpipe","slug":"video-corrupted-cannot-read-metadata-from-and-145926","errorCode":null,"errorMessage":"VIDEO_CORRUPTED: cannot read metadata from {} and no frame was produced","messagePattern":"VIDEO_CORRUPTED: cannot read metadata from (.+?) and no frame was produced","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/screenpipe-engine/src/video_utils.rs","lineNumber":1209,"sourceCode":"\n    let output = command.output().await?;\n\n    if !output.status.success() {\n        let error_message = String::from_utf8_lossy(&output.stderr);\n        info!(\"ffmpeg error: {}\", error_message);\n        if metadata_unreadable {\n            return Err(anyhow::anyhow!(\n                \"VIDEO_CORRUPTED: cannot read metadata from {} and frame extraction failed: {}\",\n                file_path,\n                error_message\n            ));\n        }\n        return Err(anyhow::anyhow!(\"ffmpeg process failed: {}\", error_message));\n    }\n\n    if !output_path.exists() {\n        if metadata_unreadable {\n            return Err(anyhow::anyhow!(\n                \"VIDEO_CORRUPTED: cannot read metadata from {} and no frame was produced\",\n                file_path\n            ));\n        }\n        return Err(anyhow::anyhow!(\"failed to extract frame: file not created\"));\n    }\n\n    // Schedule cleanup of old frames (files older than 1 hour)\n    tokio::spawn(async move {\n        if let Err(e) = cleanup_old_frames(&frames_dir).await {\n            error!(\"Failed to cleanup old frames: {}\", e);\n        }\n    });\n\n    Ok(output_path.to_string_lossy().into_owned())\n}\n\nasync fn cleanup_old_frames(frames_dir: &PathBuf) -> Result<()> {","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/screenpipe/screenpipe/blob/4ebf712990fee17eeaf904dacf749b6e96ac9bf3/crates/screenpipe-engine/src/video_utils.rs#L1191-L1227","documentation":"Raised when ffmpeg exited successfully but the expected output frame file does not exist, and the video's metadata was already found unreadable. It is the VIDEO_CORRUPTED counterpart of error 503: the source video is almost certainly unplayable, so ffmpeg 'succeeded' without producing any decodable frame.","triggerScenarios":"extract_frame_from_video on a video whose metadata is unreadable; ffmpeg command returns status success but output_path is missing — typical for zero-byte or headerless/corrupt media files.","commonSituations":"Truncated recordings from power loss; 0-byte video files; container with no decodable video stream; antivirus or sync software interfering with file reads.","solutions":["Check the file with ffprobe -i <file_path>; treat unreadable/empty files as corrupt","Skip or delete zero-byte and truncated videos before extraction","Recover the video from a backup or trigger re-recording","Ensure no other process is truncating/moving files in the video directory"],"exampleFix":"// before\nlet frame = extract_frame_from_video(path, ts, &out).await?;\n// after\nif std::fs::metadata(path).map(|m| m.len() == 0).unwrap_or(true) {\n    skip_corrupt(path);\n    return Ok(None);\n}\nlet frame = extract_frame_from_video(path, ts, &out).await?;","handlingStrategy":"validation","validationCode":"// Reject empty/unreadable videos up front\nlet md = std::fs::metadata(path)?;\nif md.len() < 1024 { skip_corrupt(path); }\n// or: ffprobe -v error <path> must succeed before extraction","typeGuard":null,"tryCatchPattern":"if let Err(e) = extract_frame_from_video(path, ts, dir).await {\n    if e.to_string().contains(\"VIDEO_CORRUPTED\") {\n        mark_corrupt(path); // persistent skip-list\n        return Ok(None);\n    }\n    return Err(e.into());\n}","preventionTips":["Skip-list files that fail this error instead of retrying forever","Watch for zero-byte files appearing in the recordings directory (crashed writers)","Verify media integrity after abnormal app shutdowns"],"tags":["ffmpeg","video-corruption","frame-extraction","rust"],"backgroundTag":"video-metadata-unreadable","analyzedSha":"4ebf712990fee17eeaf904dacf749b6e96ac9bf3","analyzedAt":"2026-09-01T23:33:43.065Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}