diff mbox

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

Message ID 8aac6f1d-3ebc-22a2-46b3-95fa4b734a8e@gmail.com
State Superseded
Headers show

Commit Message

Gyan Feb. 22, 2018, 9:03 a.m. UTC
On 2/22/2018 1:08 AM, Michael Niedermayer wrote:

> 
> this looks like its missing AV_CODEC_ID_MP1 at least

MP1 exception added.
From be49ca276c58b515e7f8e472221203c25efc6c86 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <gyandoshi@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 | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 4c6fa67fb8..bb7e4a6e8a 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -392,6 +392,11 @@  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_MP1 &&
+                       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++;
             }