Skip to content

Parses a stream of PNGs (like from ffmpeg) and emits the individual images

Notifications You must be signed in to change notification settings

stigdreyer/png-plucker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

png-plucker

A little module for parsing PNGs from streams. Useful with ffmpeg using image2pipe, for example.

png-plucker exports a single function that takes a stream and a callback that is called whenever a PNG is found in the stream. It just looks for the PNG file header, and assumes everything from a header to the next header is a single PNG, so if you have other data mixed in with PNGs you will probably get weirdness.

Installation

npm install png-plucker

Useage

var pngPlucker = require('png-plucker'),
spawn = require('child-process').spawn,
fs = require('fs'),
counter = 0,
ffmpeg;

ffmpeg = spawn('ffmpeg', ['-i', 'some_movie.mpeg', '-y', '-f', 'image2pipe', '-'])
pngsPlucker(ffmpeg.stdout, function (error, image) {
  counter++
  fs.writeFile('file'+counter+'.png', image);
});

API

pngPlucker(stream, cb)

  • stream - a stream of PNGs
  • cb(err, image) - a callback function to consume the PNGs plucked out of the stream. image is a buffer.

About

Parses a stream of PNGs (like from ffmpeg) and emits the individual images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%