A simple node server that pipes http-received data (from canvas) to ffmpeg to create videos
- You need
ffmpeg
executable installed on your machine - Edit
init
anddraw
indrawing.js
, or just modifydrawing.js
andindex.html
freely - Run
node pipeserver.js
to start the server. The port is specified inpipeserver.js
byport = 8081
. - Open
http://localhost:8081
with your browser. Or whatever port you chose. - Click
Preview Animation
to run your animation only, or clickRender
to pipe the animation to ffmpeg frame-by-frame - Check the folder for any output files
- The canvas is defined with size
1920x1080
. Changes tocx
andcy
indrawing.js
will NOT reflect to the canvas. Edit the<canvas>
element inindex.html
instead. - Whatever you specify in the
fps
input box, the preview animation will run at a fixed framerate of approximately 30 fps. Search for calls torequestAnimationFrame
inindex.html
. - The animation during rendering process runs at maximum speed (drawing, POSTing, piping and ffmpeg processing). The designated
fps
will 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
toBlob
call 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.