[FFmpeg-devel] [PATCH] avformat/rawenc: check stream type

Gyan Doshi gyandoshi at gmail.com
Wed Apr 4 13:23:25 EEST 2018


From f86916b9e1128a4e41501f4d5b189749a344862f Mon Sep 17 00:00:00 2001
From: Gyan Doshi <gyandoshi at gmail.com>
Date: Wed, 4 Apr 2018 15:45:18 +0530
Subject: [PATCH] avformat/rawenc: check stream type

Validate codec of stream to be muxed except for data muxer.
---
 libavformat/rawenc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 809ca23b1a..77cbc5f6fc 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -39,6 +39,16 @@ static int force_one_stream(AVFormatContext *s)
                s->oformat->name);
         return AVERROR(EINVAL);
     }
+
+    if (strcmp("data", s->oformat->name)) {
+        if (s->oformat->audio_codec != AV_CODEC_ID_NONE &&
+            s->oformat->audio_codec != s->streams[0]->codecpar->codec_id ||
+            s->oformat->video_codec != s->streams[0]->codecpar->codec_id) {
+            av_log(s, AV_LOG_ERROR, "Stream not of type %s\n",
+                   s->oformat->name);
+            return AVERROR(EINVAL);
+        }
+    }
     return 0;
 }
 
-- 
2.12.2.windows.2


More information about the ffmpeg-devel mailing list