[FFmpeg-devel] [PATCH] ffmpeg.c: Strip off ADTS Header from AAC audio as it is needed only in TS and not needed in 3GP, MP4, FLV, ISM formats

Chiranjeevi Melam cmelam at rgbnetworks.com
Wed Aug 24 19:04:21 CEST 2011


All,
The patch is to strip off ADTS Header from AAC audio as it is needed only in TS and not needed in 3GP, MP4, FLV, ISM formats.
Thanks,
Chiru

diff --git a/ffmpeg/ffmpeg_orig.c b/ffmpeg/ffmpeg.c index 95b3252..f860e9a 100755
--- a/ffmpeg/ffmpeg_orig.c
+++ b/ffmpeg/ffmpeg.c
@@ -1835,6 +1835,22 @@ static int output_packet(InputStream *ist, int ist_index,
                             opkt.size = sizeof(AVPicture);
                             opkt.flags |= AV_PKT_FLAG_KEY;
                         }
+
+                        if(ost->st->codec->codec_id == CODEC_ID_AAC) {
+                            if(!strcmp(input_files[ist->file_index]->iformat->name, "mpegts") && strcmp(output_files[ost->file_index]->oformat->name, "mpegts") ) {
+                                if(opkt.data[0] == 0xff && (opkt.data[1] & 0xf0) == 0xf0) {
+                                    uint32_t offset = 7;
+                                    // skip ADTS CRC
+                                    if((opkt.data[1] & 0x1) == 0x00)
+                                        offset += 2;
+                                    opkt.data  += offset;
+                                    opkt.size  -= offset;
+                                    data_size  -= offset;
+                                    audio_size -= offset;
+                                }
+                            }
+                        }
+
                         write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
                         ost->st->codec->frame_number++;
                         ost->frame_number++;


More information about the ffmpeg-devel mailing list