How to use the mp4box.MP4Box function in mp4box

To help you get started, we’ve selected a few mp4box examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gpac / mp4box.js / test / node / extract.js View on Github external
var fs = require('fs');
var mp4boxModule = require('mp4box');

if (process.argv.length > 3) {
	var mp4box = new mp4boxModule.MP4Box();
	mp4box.onReady = function(info) {		
		var found = false;
		for (var i = 0; i < info.tracks.length; i++) {
			if (info.tracks[i].id == process.argv[3]) {
				mp4box.setExtractionOptions(info.tracks[i].id);  
				found = true;
			}
		}
		if (found === false) {
			console.log("Track id "+process.argv[3]+" not found in file "+process.argv[2]);
		}
		mp4box.start();
	};
	mp4box.onSamples = function (id, user, samples) {
    	console.log("Received "+samples.length+" samples on track "+id+" for object "+user);
    	for (var i = 0; i < samples.length; i++) {
github gpac / mp4box.js / test / node / info.js View on Github external
var fs = require('fs');
var mp4boxModule = require('mp4box');

if (process.argv.length > 2) {
	var mp4box = new mp4boxModule.MP4Box();
	var arrayBuffer = new Uint8Array(fs.readFileSync(process.argv[2])).buffer;
	arrayBuffer.fileStart = 0;

	mp4box.appendBuffer(arrayBuffer);
	console.log(mp4box.getInfo());
} else {
	console.log("usage: node info.js ");
}
github gpac / mp4box.js / test / node / fragment.js View on Github external
var fs = require('fs');
var mp4boxModule = require('mp4box');

if (process.argv.length < 5) {
	console.log("usage: node fragment.js    ");
	return;
}

var out = fs.createWriteStream(process.argv[5]);

var mp4box = new mp4boxModule.MP4Box();

mp4box.onReady = function (info) {
	var found = false;
	var segOptions = { nbSamples: +process.argv[4] };
	console.log("Movie information received");
	for (var i = 0; i < info.tracks.length; i++) {
		if (info.tracks[i].id != process.argv[3]) continue;
		console.log("Segmenting track "+info.tracks[i].id+" with "+segOptions.nbSamples+" per segment");
		mp4box.setSegmentOptions(info.tracks[i].id, null, segOptions);
		found = true;
	}
	if (found) {
		var segs = mp4box.initializeSegmentation();
		out.write(toBuffer(segs[0].buffer));
		mp4box.seek(0, true);
		mp4box.start();

mp4box

JavaScript version of GPAC's MP4Box tool

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

63 / 100
Full package analysis

Popular mp4box functions