]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpegtsenc: only allow one program in m2ts mode
authorMarton Balint <cus@passwd.hu>
Tue, 10 Dec 2019 22:24:27 +0000 (23:24 +0100)
committerMarton Balint <cus@passwd.hu>
Tue, 21 Apr 2020 19:28:29 +0000 (21:28 +0200)
The standard does not allow more.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/mpegtsenc.c

index bee996ad493d0313ba38c29ab8dd852362ba3e7c..c3b9dd55d4f122c84fda3da3927e170354b67ca7 100644 (file)
@@ -869,8 +869,13 @@ static int mpegts_init(AVFormatContext *s)
     ts->m2ts_pgssub_pid  = M2TS_PGSSUB_START_PID;
     ts->m2ts_textsub_pid = M2TS_TEXTSUB_PID;
 
-    if (ts->m2ts_mode)
+    if (ts->m2ts_mode) {
         ts->pmt_start_pid = M2TS_PMT_PID;
+        if (s->nb_programs > 1) {
+            av_log(s, AV_LOG_ERROR, "Only one program is allowed in m2ts mode!\n");
+            return AVERROR(EINVAL);
+        }
+    }
 
     if (s->max_delay < 0) /* Not set by the caller */
         s->max_delay = 0;