[FFmpeg-devel] [PATCH 2/2] avformat/mpegenc - reject unsupported audio streams

Gyan Doshi gyandoshi at gmail.com
Tue Feb 20 17:17:47 EET 2018


From f0aabc7b9f959dc94084fb6d9b644104fc203566 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <gyandoshi at gmail.com>
Date: Tue, 20 Feb 2018 20:42:21 +0530
Subject: [PATCH 2/2] avformat/mpegenc - reject unsupported audio streams

Only MP2, MP3, PCM S16BE, AC3 and DTS audio codecs
are supported by the muxer.
---
 libavformat/mpegenc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 4c6fa67fb8..59e3f8c83f 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -392,6 +392,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
                 stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 4);
                 stream->lpcm_header[2] = 0x80;
                 stream->lpcm_align     = st->codecpar->channels * 2;
+            } else if (st->codecpar->codec_id != AV_CODEC_ID_MP2 &&
+                       st->codecpar->codec_id != AV_CODEC_ID_MP3) {
+                       av_log(ctx, AV_LOG_ERROR, "Unsupported audio codec. Must be one of mp2, mp3, pcm_s16be, ac3 or dts.\n");
+                       goto fail;
             } else {
                 stream->id = mpa_id++;
             }
-- 
2.12.2.windows.2


More information about the ffmpeg-devel mailing list