[FFmpeg-devel] [PATCH]Error out if mjpeg over rtp is not 4:2:0

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Jul 8 12:36:05 CEST 2015


Hi!

Looking at tickets #3823 and #4317 it seems to me that 
FFmpeg currently only supports 4:2:0 subsampling when 
sending jpeg over rtp. I believe an error should be 
shown if 4:2:2 or 4:4:4 are provided.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 31569d6..ab50ebb 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -102,6 +102,13 @@ static int rtp_write_header(AVFormatContext *s1)
 
         return -1;
     }
+    if (   st->codec->codec_id == AV_CODEC_ID_MJPEG
+        && st->codec->pix_fmt != AV_PIX_FMT_YUVJ420P
+        && st->codec->pix_fmt != AV_PIX_FMT_YUV420P) {
+        av_log(s1, AV_LOG_ERROR,
+               "Only 4:2:0 subsampling supported for (M)JPEG over rtp\n");
+        return AVERROR_PATCHWELCOME;
+    }
 
     if (s->payload_type < 0) {
         /* Re-validate non-dynamic payload types */


More information about the ffmpeg-devel mailing list