Node.js的MP4流编码和解码器:mp4-stream

jopen 8年前

Node.js的MP4流编码和解码器:mp4-stream。

npm install mp4-stream

用法

var mp4 = require('mp4-stream')  var fs = require('fs')    var decode = mp4.decode()    fs.createReadStream('video.mp4')    .pipe(decode)    .on('atom', function (atom) {      console.log('found atom (' + atom.type + ') at ' + atom.offset + ' (' + atom.length + ')')      if (atom.container) {        console.log('atom has child atoms (will be emitted next)')      }      if (atom.stream) {        console.log('atom has stream data (consume stream to continue)')        atom.stream.resume()      }    })

All atoms have a type thats a 4 char string with a type name.

API

var stream = mp4.decode()

Create a new decoder.

The decoder is a a writable stream you should write a mp4 file to. The stream will emitatomwhen a new atom is found.

var stream = mp4.encode()

Create a new encoder.

Currently not implemented

项目主页:http://www.open-open.com/lib/view/home/1446711537482