0

I have a working solution using MediaCodec and MediaExtractor, but the decoding of a 6mb MP3 takes 15 sec + encoding of 15 sec to AAC. Total of > 30 sec. I need something really fast <10 sec. Anyone know a faster solution?

EDIT

My bottleneck is from the Mediacodec itself. The bytebuffer they provide is too small. When setting up MediaFormat to AAC the InputBytebuffers are only 4096 bytes at a time is too slow for me. Its good for streaming but not for File to File.

I switch to a C lib decoder that decode in 3 sec instead of 15 sec. But the encoder still take 15 sec. Anyone has a C lib AAC encoder that can also add ADTS Headers?

Rami Kuret
  • 3,581
  • 2
  • 15
  • 17

1 Answers1

1

It sounds like you first decode the full file, then encode it. It might end up faster if you do these at the same time, i.e. when you have enough output data from the decoder to provide a full input frame to the encoder, pass it in. This can help with some parallelism, but I doubt that it helps enough to get the speedup you want.

mstorsjo
  • 12,983
  • 2
  • 39
  • 62
  • I did this but my bottleneck is from the Mediacodec itself. The bytebuffer they provide is too small. Only 4096 bytes at a time is too slow for me. I switch to a C decoder that decode in 3 sec instead of 15 sec. But the encoder still take 15 sec. Anyone has a C lib aac encoder? – Rami Kuret Feb 11 '16 at 17:47
  • This sounds quite a bit like you are using the MediaCodec API synchronously - after passing one 4096 byte buffer as input, do you wait for one output buffer before passing the next input buffer? You need to provide as many input buffers as possible and only consume output buffers as they appear in order to get proper performance from MediaCodec - see http://stackoverflow.com/a/34940871/3115956 for a longer explanation of the same. – mstorsjo Feb 11 '16 at 20:51
  • This is my logic for the encoder http://pastebin.com/uvCwKjGi. When I set up me Encoder with MediaFormat in ACC. And I do this ` inputBuffers = encoder.getInputBuffers();` (Because I need API 16) I only have 4 inputbuffers available capacity of 4096 bytes. – Rami Kuret Feb 12 '16 at 15:52