]> git.sesse.net Git - ffmpeg/commitdiff
lavf/rawenc: Only accept the appropriate stream type for raw muxers.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Sun, 30 Jun 2019 22:37:08 +0000 (00:37 +0200)
committerJames Almer <jamrial@gmail.com>
Fri, 6 Sep 2019 19:22:44 +0000 (16:22 -0300)
This does not affect the rawvideo muxer.

Fixes ticket #7979.

libavformat/rawenc.c

index 993d232b70c939d8bf16812e285e93b826c5f802..32704f9bfdf5df3b41cb7e2e8ba74d7473655be9 100644 (file)
@@ -39,6 +39,18 @@ static int force_one_stream(AVFormatContext *s)
                s->oformat->name);
         return AVERROR(EINVAL);
     }
+    if (   s->oformat->audio_codec != AV_CODEC_ID_NONE
+        && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
+        av_log(s, AV_LOG_ERROR, "%s files have exactly one audio stream\n",
+               s->oformat->name);
+        return AVERROR(EINVAL);
+    }
+    if (   s->oformat->video_codec != AV_CODEC_ID_NONE
+        && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
+        av_log(s, AV_LOG_ERROR, "%s files have exactly one video stream\n",
+               s->oformat->name);
+        return AVERROR(EINVAL);
+    }
     return 0;
 }