PR #25412 opened by andrey-khamukhin URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25412 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25412.patch
When ingesting RTSP that is carrying an MJPEG video stream, ffmpeg was not aware of the attribute x-dimensions, causing it to incorrectly detect picture size as 0x0. x-dimensions is used when either the height or the width is above 2040 pixels. Fixes [https://trac.ffmpeg.org/ticket/10296](https://trac.ffmpeg.org/ticket/10296) >From 19d2644159991dc9bc5d516e4e04029dbec842db Mon Sep 17 00:00:00 2001 From: Andrey Khamukhin <[email protected]> Date: Sat, 24 Oct 2026 03:09:55 +0300 Subject: [PATCH] libavformat/rtpdec_jpeg: use x-dimensions when rtp packet has picture size 0x0 When ingesting RTSP that is carrying an MJPEG video stream, ffmpeg was not aware of the attribute x-dimensions, causing it to incorrectly detect picture size as 0x0. x-dimensions is used when either the height or the width is above 2040 pixels. Signed-off-by: Andrey Khamukhin <[email protected]> --- libavformat/rtpdec_jpeg.c | 12 +++++++++--- libavformat/rtsp.c | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c index 1e353780940..882229f4121 100644 --- a/libavformat/rtpdec_jpeg.c +++ b/libavformat/rtpdec_jpeg.c @@ -216,7 +216,8 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, const uint8_t *buf, int len, uint16_t seq, int flags) { - uint8_t type, q, width, height; + uint8_t type, q; + uint32_t width, height; const uint8_t *qtables = NULL; uint16_t qtable_len; uint32_t off; @@ -233,8 +234,13 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, q = AV_RB8(buf + 5); /* quantization factor (or table id) */ width = AV_RB8(buf + 6); /* frame width in 8 pixel blocks */ height = AV_RB8(buf + 7); /* frame height in 8 pixel blocks */ - st->codecpar->width = width*8; - st->codecpar->height = height*8; + if (width != 0 && height != 0) { + st->codecpar->width = width * 8; + st->codecpar->height = height * 8; + } else { + width = (st->codecpar->width + 7) / 8; + height = (st->codecpar->height + 7) / 8; + } buf += 8; len -= 8; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 29f219c366a..7f0261e04a4 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -737,6 +737,13 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, } } } + } else if (av_strstart(p, "x-dimensions:", &p)) { + int width, height; + if (av_sscanf(p, "%d,%d", &width, &height) == 2) { + st = s->streams[s->nb_streams - 1]; + st->codecpar->width = width; + st->codecpar->height = height; + } } else { if (rt->server_type == RTSP_SERVER_WMS) ff_wms_parse_sdp_a_line(s, p); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
