1

Using MediaExtractor with AAC-LC file obtained from MediaRecorder :

  `val mediaExtractor = MediaExtractor()
     mediaExtractor.setDataSource(filePath) 
     val trackCount  = mediaExtractor.trackCount`

The track count is 0 for some of the files while it works fine for other AAC-LC files. All files are playable on other platforms.Faulty AAC File

 `recorder = MediaRecorder().apply {
                setAudioSource(MediaRecorder.AudioSource.MIC);
                setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
                setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
                setOutputFile(pipe[1].fileDescriptor);
                setAudioSamplingRate(dataRecorder.audioSamplingRate)
                setAudioEncodingBitRate(bitrate)
                setOnErrorListener { mr, what, extra ->
                    logger.msgToFile(
                        tag,
                        "handlerStartRecorder",
                        "Recording stopped with error : $what : $extra"
                    )
                    handler.post {
                        handlerRestartRecorder()
                    }
                }
                prepare()
                start()
            }`

I am using MediaRecorder with ParcelFileDescriptor pipe structure. When writing to the file some of the samples might have been skipped but the file always starts with the AAC ADTS header and ends with the whole sample.

Does skipping a few frames affect MediaExtractor. As per AAC ADTS each frame has it's own header and can be decoded so give that we have a whole frame, why is media extraction failing?

0 Answers0