Skip to content
/ deream Public

Encode PNG Buffer stream to movie with ffmpeg, on Node.js / Electron

License

Notifications You must be signed in to change notification settings

hanakla/deream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deream

Example

Currently not perfectly support .pipe(writableStream)

import deream from 'deream';
import Canvas from 'canvas';

const streamIn = deream({
    args: {
        // ffmpeg options
        'y' : '',
        'c:v': 'libx264',
        'b:v': '1024k',
        'r:v': '30'
    },
    // path to destination file
    dest: 'dest.mp4',
});


const canvas = new Canvas(640, 360);
const context = canvas.getContext('2d');

// make 2seconds/30fps movie
for (let i = 0; i < 60; i++) {
    const frameHex = `00${i.toString(16)}`.slice(-2);
    context.fillStyle = ['#', frameHex, frameHex, frameHex].join('');
    context.fillRect(0, 0, 640, 360);

    // write PNG Buffer
    streamIn.write(canvas.toBuffer());
}

streamIn.end();

About

Encode PNG Buffer stream to movie with ffmpeg, on Node.js / Electron

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published