Skip to content

Instantly share code, notes, and snippets.

@JosePedroDias
Last active September 13, 2017 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosePedroDias/35f9959b644af197242c7ac471f02169 to your computer and use it in GitHub Desktop.
Save JosePedroDias/35f9959b644af197242c7ac471f02169 to your computer and use it in GitHub Desktop.

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