A simple node server that pipes http-received data (from canvas) to ffmpeg to create videos
- You need
ffmpegexecutable installed on your machine - Edit
initanddrawindrawing.js, or just modifydrawing.jsandindex.htmlfreely - Run
node pipeserver.jsto start the server. The port is specified inpipeserver.jsbyport = 8081. - Open
http://localhost:8081with your browser. Or whatever port you chose. - Click
Preview Animationto run your animation only, or clickRenderto pipe the animation to ffmpeg frame-by-frame - Check the folder for any output files
- The canvas is defined with size
1920x1080. Changes tocxandcyindrawing.jswill NOT reflect to the canvas. Edit the<canvas>element inindex.htmlinstead. - Whatever you specify in the
fpsinput box, the preview animation will run at a fixed framerate of approximately 30 fps. Search for calls torequestAnimationFrameinindex.html. - The animation during rendering process runs at maximum speed (drawing, POSTing, piping and ffmpeg processing). The designated
fpswill be reflected in the output video. - Therefore, you should NEVER rely on fps to retreive images from sources like
<video> - Sound is not currently supported. You might want to add soundtracks to the file later, or write something to pipe WebAudio to FFMPEG before I do (send me a link, thanks, lol).
- The program runs by sending PNG sequences, which might crash certain versions of FFMPEG due to an issue. Check your version and either upgrade it or modify the
toBlobcall inindex.html - More information about FFMPEG can be found on ffmpeg.org
This is a simple code snippet dedicated to the public domain. You can do whatever you like with it.