1

We have an m4a audio file a container for a AAC encoded audio (container stream is mpeg-4, audio stream is AAC).

We are transmitting this file in pieces (just breaking it randomly, at our size limit, and transmitting those bytes) between 2 systems.

If a piece never gets sent, then how do I reconstitute the pieces so at least some of it is playable?

What I've found so far is that if I break up the file and send it I can reconstitute it if I have all the pieces (of course), but if I leave a piece out, no audio tool recognizes it or can play it.

What is the correct way to do this? How is m4a a streamable format if I need all the pieces?

Edit: to clarify we are recording audio on limited IoT devices and sending the recordings to the cloud for later playback. We have max upload size of 128kb. We could simply save the raw audio into many small m4a files originally and just upload those but isn't there some wastage there with all the meta-data in each file? Like we want 30s of audio but save that into 10, 3s m4a files instead of one 30s m4a file that we split up?

Fraggle
  • 8,607
  • 7
  • 54
  • 86

1 Answers1

1

I'd extract your AAC stream out of your MPEG-4 (m4a) container and put your AAC into ADTS (Audio Data Transport Stream). ADTS consists of small frames and each frame has a header followed by AAC audio data (similar to an MP3 stream). ADTS is self synchronizing and is designed for packet loss - for example for over the air transmission.

Markus Schumann
  • 7,636
  • 1
  • 21
  • 27
  • Ok, not sure we can do that on the client side. We have limitations. But I can investigate. So is the answer to my original question about reconstituting an m4a with missing piece: "that is impossible, use a different encoding/container format or save each chunk as a complete m4a file"? – Fraggle Nov 23 '17 at 03:24
  • 1
    Turning your AAC/M4A into a ADTS - you don't have to re-encode. – Markus Schumann Nov 23 '17 at 03:53
  • @Fraggle You don't do this client-side, you do this server-side. Without something like ADTS, you can't arbitrarily reassemble the stream. – Brad Nov 23 '17 at 04:04
  • 2
    Missing random bytes from an mp4/m4a is tricky. Your file could be (sample table followed by samples) or (samples followed by sample table). If you loose any bytes from the sample table - the reconstruction is pretty hard and there is no redundancy. Loosing a known amount of sample bytes may be recoverable. I'd try inserting zeros. If your file is you could play a truncated file - most players would do it. – Markus Schumann Nov 23 '17 at 04:07