{"record":{"id":"b66ecb0ddf8704ea","repo":"AlexxIT/go2rtc","slug":"y4m-unsupported-format-s","errorCode":null,"errorMessage":"y4m: unsupported format: %s","messagePattern":"y4m: unsupported format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/y4m/producer.go","lineNumber":24,"sourceCode":"\t\"io\"\n\n\t\"github.com/AlexxIT/go2rtc/pkg/core\"\n\t\"github.com/pion/rtp\"\n)\n\nfunc Open(r io.Reader) (*Producer, error) {\n\trd := bufio.NewReaderSize(r, core.BufferSize)\n\tb, err := rd.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb = b[:len(b)-1] // remove \\n\n\n\tfmtp := ParseHeader(b)\n\n\tif GetSize(fmtp) == 0 {\n\t\treturn nil, errors.New(\"y4m: unsupported format: \" + string(b))\n\t}\n\n\tmedias := []*core.Media{\n\t\t{\n\t\t\tKind:      core.KindVideo,\n\t\t\tDirection: core.DirectionRecvonly,\n\t\t\tCodecs: []*core.Codec{\n\t\t\t\t{\n\t\t\t\t\tName:        core.CodecRAW,\n\t\t\t\t\tClockRate:   90000,\n\t\t\t\t\tFmtpLine:    fmtp,\n\t\t\t\t\tPayloadType: core.PayloadTypeRAW,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\treturn &Producer{\n\t\tConnection: core.Connection{","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/y4m/producer.go#L6-L42","documentation":"pkg/y4m.Open parses a Y4M (YUV4MPEG2) header and computes the frame size with GetSize. If GetSize returns 0, the header's colorspace/format parameter (e.g. C420jpeg, C422, C444...) is not a format the library can size, meaning the pixel format is unsupported and Open refuses the stream. The error message includes the raw header line for diagnosis.","triggerScenarios":"Calling y4m Open on a file whose header contains an unsupported 'C' colorspace parameter (or a header missing the dimension parameters entirely), making frame size computation impossible.","commonSituations":"Feeding Y4M files with exotic colorspaces (C420p10, C420, alpha planes) generated by ffmpeg with high-bit-depth pixel formats; truncated or corrupted headers; test patterns from tools emitting non-standard Y4M variants.","solutions":["Convert the file to a standard 8-bit 4:2:0 Y4M: ffmpeg -i in.y4m -pix_fmt yuv420p -f rawvideo - | with a y4m header, e.g. use -f yuv4mpegpipe -pix_fmt yuv420p","Inspect the header line shown in the error to see the offending C parameter","Regenerate the source with 8-bit pixel formats (yuv420p/yuv422p/yuv444p) rather than 10/12-bit"],"exampleFix":"// before\nffmpeg -i in.mp4 -pix_fmt yuv420p10le -f yuv4mpegpipe out.y4m // unsupported\n// after\nffmpeg -i in.mp4 -pix_fmt yuv420p -f yuv4mpegpipe out.y4m","handlingStrategy":"validation","validationCode":"// parse the y4m header before opening\nfmtp := y4m.ParseHeader(headerBytes)\nif y4m.GetSize(fmtp) == 0 {\n    // convert with ffmpeg -pix_fmt yuv420p -f yuv4mpegpipe first\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"unsupported format\") {\n        // fall back to a transcoded copy of the input\n    }\n    return err\n}","preventionTips":["Generate Y4M only with 8-bit standard colorspaces (C420jpeg/C420mpeg2/C422/C444)","Validate input media pixel formats in the ingestion pipeline"],"tags":["y4m","video","format","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}