Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

415
Vistas
Browser JS: How to extract aac audio data from a mp4 file?

Using browser JavaScript, I need to load mp4-files containing AAC audio data, and extract this audio data for later use.

There is an mdat block in the mp4 file that (to my understanding) holds the embedded aac data, but just extracting the contents of that mdata block does not seem to give me valid aac data.

So, what is the simplest way to - in the browser - get embedded aac audio data out of a mp4 container file?

Edit:

Looking deeper into this, using some hexfile analysis, reveals the reason why aac decoding fails when just grabbing the data from the mdat block:

As seen in the illustration below - where the file structure of an example.aac file and an example.mp4 file containing the identical audio data are compared - there's a clear difference in the way data is stored:

In the original aac data, chunks of compressed audio data are separated with strings of something like FF F1 4C 80 ** ** FC (red in illustration). In the mp4 version, the exact same data (green in illustration) doesn't have this separation.

enter image description here

To solve my case, I have to work backwards, I guess: Grab the compressed "unseparated" data from the .mp4 file, and "inject" the separating string in order to get aac decoders to recognize it as valid...

So, does anyone know where to find information about this "aac data-separating string" and how to in the browser inject it into the mp4 data resulting in a valid aac file block?

Edit2:

Further investigation shows that .mp4 stores the aac data as "aac raw", without 7 bytes ADTS headers separating the compressed audio frames.

Syu Kato's mp4.js script (https://github.com/ukyo/mp4.js) has an extractRawAudio(mp4DataAsUInt8Array) method that can extract the raw aac data and inject the needed frame headers, wHich solves the problem for me.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda