AlexxIT/go2rtc · error
y4m: unsupported format
Error message
y4m: unsupported format: %s
What it means
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.
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
Example fix
// before ffmpeg -i in.mp4 -pix_fmt yuv420p10le -f yuv4mpegpipe out.y4m // unsupported // after ffmpeg -i in.mp4 -pix_fmt yuv420p -f yuv4mpegpipe out.y4m
Defensive patterns
Strategy: validation
Validate before calling
// parse the y4m header before opening
fmtp := y4m.ParseHeader(headerBytes)
if y4m.GetSize(fmtp) == 0 {
// convert with ffmpeg -pix_fmt yuv420p -f yuv4mpegpipe first
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "unsupported format") {
// fall back to a transcoded copy of the input
}
return err
} Prevention
- Generate Y4M only with 8-bit standard colorspaces (C420jpeg/C420mpeg2/C422/C444)
- Validate input media pixel formats in the ingestion pipeline
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- ErrCantGetTrack
- kasa: unsupported type:
- nest: invalid cache key format
- v4l2: invalid video_size
- v4l2: invalid input_format
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/b66ecb0ddf8704ea.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/y4m/producer.go:24
"io"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/pion/rtp"
)
func Open(r io.Reader) (*Producer, error) {
rd := bufio.NewReaderSize(r, core.BufferSize)
b, err := rd.ReadBytes('\n')
if err != nil {
return nil, err
}
b = b[:len(b)-1] // remove \n
fmtp := ParseHeader(b)
if GetSize(fmtp) == 0 {
return nil, errors.New("y4m: unsupported format: " + string(b))
}
medias := []*core.Media{
{
Kind: core.KindVideo,
Direction: core.DirectionRecvonly,
Codecs: []*core.Codec{
{
Name: core.CodecRAW,
ClockRate: 90000,
FmtpLine: fmtp,
PayloadType: core.PayloadTypeRAW,
},
},
},
}
return &Producer{
Connection: core.Connection{View on GitHub (pinned to c245815e75)