{"record":{"id":"efa3dbeae4608709","repo":"remotion-dev/remotion","slug":"the-codec-is-not-a-video-codec","errorCode":null,"errorMessage":"The codec is not a video codec","messagePattern":"The codec is not a video codec","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"packages/compositor/rust/get_video_metadata.rs","lineNumber":334,"sourceCode":"        };\n\n        // Return the video metadata\n        let metadata = VideoMetadata {\n            fps,\n            width: video.width(),\n            height: video.height(),\n            durationInSeconds,\n            codec: video_codec_name,\n            canPlayInVideoTag,\n            supportsSeeking,\n            colorSpace,\n            audioCodec: audio_codec_name,\n            audioFileExtension: audio_file_extension,\n            pixelFormat,\n        };\n        Ok(metadata)\n    } else {\n        return Err(std::io::Error::new(\n            ErrorKind::Other,\n            \"The codec is not a video codec\",\n        ))?;\n    }\n}\n","sourceCodeStart":316,"sourceCodeEnd":340,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/compositor/rust/get_video_metadata.rs#L316-L340","documentation":"Thrown by get_video_metadata when the best video stream's decoder is not an ffmpeg video decoder (context.decoder().video() fails or yields a non-video codec). The metadata path requires a real video codec to read width/height/pixel format.","triggerScenarios":"The stream selected as 'best video' resolves to a codec context that cannot be opened as a video decoder — e.g. an attached-picture (mjpeg) stream, a data/overlay stream, or a codec unsupported by the linked ffmpeg.","commonSituations":"Probing a container with an embedded cover-art/album-art stream that ffmpeg ranks as the best video stream; using an ffmpeg build without the codec (e.g. hevc disabled); corrupted codec parameters in the header.","solutions":["Run `ffprobe -show_streams <file>` and check the selected video stream's codec_name and whether ffmpeg can decode it.","Re-mux/re-encode the file so the primary video stream uses a supported codec.","Rebuild ffmpeg with the required decoder (e.g. --enable-decoder=hevc)."],"exampleFix":"// before\nconst meta = await getVideoMetadata(file);\n\n// after (CLI verification)\n// $ ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of csv=p=0 file\n// ensure it prints a real video codec (h264, hevc, vp9, av1), not mjpeg/png","handlingStrategy":"validation","validationCode":"// CLI check before metadata call:\n// $ ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,codec_type -of csv=p=0 <file>\n// ensure codec_type=video and codec_name is a supported decoder","typeGuard":"null","tryCatchPattern":"match get_video_metadata(path) {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"not a video codec\") => fallback_metadata(),\n    Err(e) => return Err(e),\n}","preventionTips":["Confirm the primary video stream's codec is one ffmpeg can decode.","Re-encode cover-art-only containers to a real video codec.","Build ffmpeg with the decoders you need (hevc, av1, vp9)."],"tags":["rust","ffmpeg","video","codec","media-metadata"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}