Write broken aac frames to mov files instead of skipping them.
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Sat, 30 Mar 2013 07:41:46 +0000 (08:41 +0100)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Tue, 2 Apr 2013 10:57:35 +0000 (12:57 +0200)
Fixes decoding with picky media players.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit b448c0a68d0cc7dfef736267dfdaed0e213c020b)

Conflicts:
libavformat/movenc.c

libavformat/movenc.c

index 1526944..43bda7f 100644 (file)
@@ -2249,6 +2249,14 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
             return -1;
     }
 
+    if (enc->codec_id == 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");
+    }
     if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) {
         /* from x264 or from bytestream h264 */
         /* nal reformating needed */
@@ -2262,13 +2270,6 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
             trk->cluster[trk->entry].data= buf;
         }else
             size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
-    } else if (enc->codec_id == 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 if (mov->frag_seq_num>0){
         trk->cluster[trk->entry].data = av_malloc(size);
         if (!trk->cluster[trk->entry].data)