{"record":{"id":"3b3ed5773fceafec","repo":"remotion-dev/remotion","slug":"not-enough-planes-or-linesizes","errorCode":null,"errorMessage":"Not enough planes or linesizes","messagePattern":"Not enough planes or linesizes","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"packages/compositor/rust/fix_dimensions.rs","lineNumber":18,"sourceCode":"use std::io::ErrorKind;\n\nuse ffmpeg_next::format::Pixel;\n\n// Calculate dimensions based on linesize, not based on metadata\npub fn get_dimensions_from_planes(\n    pixel_format: Pixel,\n    planes: &[Vec<u8>],\n    linesizes: &[i32; 8],\n    original_width: u32,\n    original_height: u32,\n) -> Result<(u32, u32), std::io::Error> {\n    if pixel_format != Pixel::YUV420P {\n        return Ok((original_width, original_height));\n    }\n\n    if planes.len() < 3 || linesizes.len() < 3 {\n        return Err(std::io::Error::new(\n            ErrorKind::Other,\n            \"Not enough planes or linesizes\",\n        ));\n    }\n\n    // Calculate dimensions for each plane based on linesizes\n    let y_height = planes[0].len() as u32 / linesizes[0] as u32;\n    let y_width = linesizes[0] as u32;\n\n    // Believe the original width, but do not allow overflow\n    Ok((y_width.min(original_width), y_height.min(original_height)))\n}\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/compositor/rust/fix_dimensions.rs#L1-L31","documentation":"Thrown by get_dimensions_from_planes when decoding a YUV420P frame whose plane/linesize arrays have fewer than 3 entries. The function derives width/height from Y/U/V planes, so all three planes and linesizes must be present for any format other than YUV420P (which returns early with the original dimensions). This indicates malformed or truncated decoded frame data passed from ffmpeg.","triggerScenarios":"Calling get_dimensions_from_planes with pixel_format == Pixel::YUV420P but planes.len() < 3 or linesizes containing fewer than 3 populated slots (the array is fixed at 8 but only some are set by the decoder). Happens when a hardware/decoded frame surfaces incomplete plane data, or an upstream filter drops subplanes.","commonSituations":"Corrupt or truncated source media where ffmpeg partially decodes YUV420P; mismatches between the ffmpeg-next version and the planes the decoder emits; feeding manually-constructed plane arrays that omit chroma planes.","solutions":["Re-encode or replace the source media with a valid YUV420P file that ffmpeg can fully decode.","Before calling, assert planes.len() >= 3 and that linesizes[0..3] are non-zero, falling back to original_width/original_height if not.","Upgrade/rematch the ffmpeg-next crate version to one consistent with the linked ffmpeg libraries."],"exampleFix":"// before\nlet dims = get_dimensions_from_planes(fmt, &planes, &linesizes, w, h)?;\n\n// after\nif fmt == Pixel::YUV420P && (planes.len() < 3 || linesizes[0] == 0 || linesizes[1] == 0 || linesizes[2] == 0) {\n    return Ok((w, h)); // fall back, do not crash on partial planes\n}\nlet dims = get_dimensions_from_planes(fmt, &planes, &linesizes, w, h)?;","handlingStrategy":"validation","validationCode":"fn can_get_dimensions(pixel_format: Pixel, planes: &[Vec<u8>], linesizes: &[i32; 8]) -> bool {\n    if pixel_format != Pixel::YUV420P { return true; }\n    planes.len() >= 3 && linesizes[0] > 0 && linesizes[1] > 0 && linesizes[2] > 0\n}\n// call before get_dimensions_from_planes; fall back to (original_width, original_height)","typeGuard":"null","tryCatchPattern":"match get_dimensions_from_planes(fmt, &planes, &linesizes, w, h) {\n    Ok(d) => d,\n    Err(_) => (w, h), // tolerate partial planes, use declared dims\n}","preventionTips":["Reject/truncate sources ffmpeg cannot fully decode.","Keep the ffmpeg-next crate version in sync with linked libraries.","Unit-test the YUV420P path with synthetic 3-plane frames."],"tags":["rust","ffmpeg","video-decode","yuv420p","corrupt-media"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}