Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Allows one to preview MPEG ISO BMFF atoms in JS. ISO BMFF MPEG4 Atom Registry

Assumes the mp4lib from Orange though shouldn't differ much in other impls.

Example output:

/ 
  ftyp 28
  moov 679
    mvhd 120
    trak 511
      tkhd 104
      mdia 399
        mdhd 44
        hdlr 44
        minf 303
          vmhd 20
          dinf 36
            dref 28
              url  12
          stbl 239
            stts 16
            stsc 16
            stco 16
            stsz 20
            stsd 163
              avc1 147
                avcC 61
    mvex 40
      trex 32
function spaces(n) {
return new Array(n + 1).join(' ');
}
function printAtom(a, ind) {
ind = ind || 0;
const s = 'size' in a ? a.size : '';
const b = 'boxes' in a ? a.boxes : [];
const t = 'boxtype' in a ? a.boxtype : '/';
return spaces(ind) + t + ' ' + s + '\n' + b.map(function(a2) {
return printAtom(a2, ind + 1);
}).join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment