Browse code

lavf/rawenc: Only accept the appropriate stream type for raw muxers.

This does not affect the rawvideo muxer.

Fixes ticket #7979.

(cherry picked from commit aef24efb0c1e65097ab77a4bf9264189bdf3ace3)

Carl Eugen Hoyos authored on 2019/07/01 07:37:08
Showing 1 changed files
... ...
@@ -39,6 +39,18 @@ static int force_one_stream(AVFormatContext *s)
39 39
                s->oformat->name);
40 40
         return AVERROR(EINVAL);
41 41
     }
42
+    if (   s->oformat->audio_codec != AV_CODEC_ID_NONE
43
+        && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
44
+        av_log(s, AV_LOG_ERROR, "%s files have exactly one audio stream\n",
45
+               s->oformat->name);
46
+        return AVERROR(EINVAL);
47
+    }
48
+    if (   s->oformat->video_codec != AV_CODEC_ID_NONE
49
+        && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
50
+        av_log(s, AV_LOG_ERROR, "%s files have exactly one video stream\n",
51
+               s->oformat->name);
52
+        return AVERROR(EINVAL);
53
+    }
42 54
     return 0;
43 55
 }
44 56