eugeneware / gifencoder

Server side animated gif generation for node.js
Other
472 stars 49 forks source link

Piping html-png-stream to GIFEncoder results black frames #13

Closed jussikinnula closed 7 years ago

jussikinnula commented 7 years ago

See example code at: https://github.com/jussikinnula/html-png-stream-gifencoder-test

Most probably https://github.com/eugeneware/html-png-stream module needs to be changed to work similarly as https://github.com/eugeneware/png-file-stream is done.

I tried already to do this, but didn't manage do it otherwise than by using Canvas (which is generally way too slow). It would be best if GIFEncoder would accept the Buffer data passed by html-png-stream, or create a middleware to transform the stream to one that can be accepted by GIFEncoder.

heikkipora commented 7 years ago

@jussikinnula GIFEncoder accepts a stream of RGBA buffers whereas html-png-stream produces buffers encoded as PNG. You will need a "middleware" to decode the PNG buffers - like you did with the Canvas. I don't think any other method (for decoding the PNGs) would be considerably faster as that phase is not the bottleneck. Rendering a HTML document to a PNG file in an external phantomjs process is where the time is spent.