iso_base_media 1.4.0 copy "iso_base_media: ^1.4.0" to clipboard
iso_base_media: ^1.4.0 copied to clipboard

A dart package to parse ISO Base Media File Format and MP4 files.

iso_base_media #

pub package Build Status

Usage #

Inspect all boxes (atoms) in an ISO base media format file #

Future<void> inspect() async {
  final fileBox = await ISOFileBox.open('./test/test_files/a.heic');
  final s = await inspectISOBox(fileBox);
  await fileBox.close();
  print(s);
}
/*
  [
    [
      {'boxSize': 24, 'dataSize': 16, 'type': 'ftyp'}
    ],
    [
      {'boxSize': 510, 'dataSize': 498, 'type': 'meta', 'fullBoxInt32': 0},
      [
        {'boxSize': 33, 'dataSize': 21, 'type': 'hdlr', 'fullBoxInt32': 0}
      ],
      [
        {'boxSize': 14, 'dataSize': 2, 'type': 'pitm', 'fullBoxInt32': 0}
      ],
      [
        {'boxSize': 52, 'dataSize': 40, 'type': 'iloc', 'fullBoxInt32': 0}
      ],
      [
        {'boxSize': 76, 'dataSize': 64, 'type': 'iinf', 'fullBoxInt32': 0}
      ],
      [
        {'boxSize': 26, 'dataSize': 14, 'type': 'iref', 'fullBoxInt32': 0},
        [
          {'boxSize': 14, 'dataSize': 6, 'type': 'thmb'}
        ]
      ],
      [
        {'boxSize': 297, 'dataSize': 289, 'type': 'iprp'},
        [
          {'boxSize': 263, 'dataSize': 255, 'type': 'ipco'}
        ],
        [
          {'boxSize': 26, 'dataSize': 18, 'type': 'ipma'}
        ]
      ]
    ],
    [
      {'boxSize': 293074, 'dataSize': 293066, 'type': 'mdat'}
    ]
  ]
*/

Extract data from specific boxes #

Future<void> extract() async {
  final fileBox = await ISOFileBox.open('./test/test_files/a.heic');
  var s = '';
  await inspectISOBox(fileBox, callback: (box, depth) async {
    if (box.type == 'ispe') {
      final data = await box.extractData();
      s += '${uint8ListToHex(data)}\n';
    }
  });
  await fileBox.close();
  print(s);
}

String uint8ListToHex(Uint8List bytes) {
  final StringBuffer buffer = StringBuffer();
  buffer.write('bytes(${bytes.length}): ');
  for (int byte in bytes) {
    buffer.write(byte.toRadixString(16).padLeft(2, '0'));
    buffer.write(' ');
  }
  return buffer.toString();
}

/*
bytes(12): 00 00 00 00 00 00 05 a0 00 00 03 c0
bytes(12): 00 00 00 00 00 00 00 f0 00 00 00 a0
*/

Start parsing from a RandomAccessFile #

final fileBox = await ISOFileBox.openRandomAccessFile(someRandomAccessFile);
// It's now user's responsibility to close the random access file.
0
likes
0
pub points
55%
popularity

Publisher

verified publishermgenware.com

A dart package to parse ISO Base Media File Format and MP4 files.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on iso_base_media