diff mbox

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

Message ID 78c58058-a363-4f79-c3e2-31f90ba0c8ec@gmail.com
State New
Headers show

Commit Message

Gyan Feb. 23, 2018, 5:05 a.m. UTC
On 2/23/2018 3:50 AM, Carl Eugen Hoyos wrote:
> 
> Please also mention "mp1" and "pcm_dvd" in the log message.

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

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

Comments

Gyan Feb. 26, 2018, 5:27 p.m. UTC | #1
On 2/23/2018 10:35 AM, Gyan Doshi wrote:
> 
> 
> On 2/23/2018 3:50 AM, Carl Eugen Hoyos wrote:
>>
>> Please also mention "mp1" and "pcm_dvd" in the log message.
> 
> Revised patch attached.

Ping.
Carl Eugen Hoyos Feb. 26, 2018, 11:14 p.m. UTC | #2
2018-02-23 6:05 GMT+01:00 Gyan Doshi <gyandoshi@gmail.com>:
>
>
> On 2/23/2018 3:50 AM, Carl Eugen Hoyos wrote:
>>
>>
>> Please also mention "mp1" and "pcm_dvd" in the log message.
>
>
> Revised patch attached.

"16 bit" seems useless to me, even more so as all other strings
are the FFmpeg codec names (as opposed to generally used
names) which seems a very good idea to me.

Carl Eugen
Gyan Feb. 27, 2018, 4:42 a.m. UTC | #3
On 2/27/2018 4:44 AM, Carl Eugen Hoyos wrote:
> 
> "16 bit" seems useless to me, even more so as all other strings
> are the FFmpeg codec names (as opposed to generally used
> names) which seems a very good idea to me.

20 and 24 bit PCM DVD streams cannot be muxed, as the packet header and 
block size written by the muxer is hardcoded for 16-bit, so an 
unqualified 'pcm_dvd' would be inaccurate.

Regards,
Gyan
diff mbox

Patch

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 4c6fa67fb8..8b33468dff 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 mp1, mp2, mp3, 16-bit pcm_dvd, pcm_s16be, ac3 or dts.\n");
+                       goto fail;
             } else {
                 stream->id = mpa_id++;
             }