Only test the first frame for missing aac_adtstoasc bistream filter.
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Tue, 26 Mar 2013 14:16:07 +0000 (15:16 +0100)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Tue, 26 Mar 2013 23:56:35 +0000 (00:56 +0100)
Many players ignore broken aac frames, so don't abort mov or flv
muxing when encountering one, just print a warning instead.

Fixes ticket #2380.
(cherry picked from commit 1741fece7073f51efdd837a4f307ea2cdf3d1cfb)

libavformat/flvenc.c
libavformat/movenc.c

index 97c00bf..5447840 100644 (file)
@@ -492,10 +492,13 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
                 return ret;
     } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
                (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
+        if (!s->streams[pkt->stream_index]->nb_frames) {
         av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
                "use audio bistream filter 'aac_adtstoasc' to fix it "
                "('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
         return AVERROR_INVALIDDATA;
+        }
+        av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
     }
 
     if (flv->delay == AV_NOPTS_VALUE)
index 5bf5a74..18dbffa 100644 (file)
@@ -3097,8 +3097,11 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
                (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
+        if (!s->streams[pkt->stream_index]->nb_frames) {
         av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n");
         return -1;
+        }
+        av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
     } else {
         avio_write(pb, pkt->data, size);
     }