Skip to content

Split a concatenated stream of PNG images into individual PNG frames

License

Notifications You must be signed in to change notification settings

eugeneware/png-split-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

png-split-stream

Split a concatenated stream of PNG images into individual PNG frames

build status

Installation

This module is installed via npm:

$ npm install png-split-stream

Example Usage

Reading a concatenated PNG file

var pngSplitStream = require('png-split-stream');

// all.png is a concatenation of multiple PNGs
// eg. `cat a.png b.png > all.png`
fs.createReadStream(__dirname + '/fixtures/all.png')
  .pipe(pngSplitStream())
  .on('data', function(data) {
    // each 'data' event contains one of the whole images as a single chunk
    console.log(data.slice(1, 4));
    // 'PNG'
  });

Splitting an ffmpeg image2pipe PNG stream

var ffmpegBin = require('ffmpeg-static');
var spawn = require('child_process').spawn;
var ffmpeg = spawn(ffmpegBin.path, [
  '-i', 'myfile.mp4',
  '-f', 'image2pipe',
  '-vcodec', 'png',
  '-'
]);
ffmpeg.stdout
  .pipe(pngSplitStream())
  .on('data', function (data) {
    // each 'data' event contains one of the frames from the video as a single chunk
    console.log(data.slice(1, 4));
    // 'PNG'
  });

Acknowledgements

This code was heavily adapted and stripped down for just splitting purposes from @devongott/png-stream.

About

Split a concatenated stream of PNG images into individual PNG frames

Resources

License

Stars

Watchers

Forks

Packages

No packages published