Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracker: GIFBuilder #765

Closed
1 of 6 tasks
ibgreen opened this issue Jun 3, 2020 · 6 comments
Closed
1 of 6 tasks

tracker: GIFBuilder #765

ibgreen opened this issue Jun 3, 2020 · 6 comments
Assignees

Comments

@ibgreen
Copy link
Collaborator

ibgreen commented Jun 3, 2020

File size

  • Add test setup (set of images to compress). @chrisgervang
  • Compare with GIF optimizers to get baseline for what good file size looks like @chrisgervang

Encoding performance

  • Experiment with 'sampleInterval': option @chrisgervang
  • See if increasing the number of workers help. @chrisgervang
  • Modify API to start encoding when first image is added (parallelize rendering and encoding).

General

  • Code cleanup - Cut out non-essential gifshot code related to webcam etc. Convert code to ES6.
@chrisgervang
Copy link
Collaborator

The settings of the intermediate capture (the images of the captured canvas) play a significant role on performance (less so on final file size), so I think tuning with a hubble/deck setup in addition to test images is important for the benchmark to get a full idea.

@chrisgervang
Copy link
Collaborator

frameDuration: 1, // The amount of time (10 = 1s) to stay on each frame

I don't think their documentation on frameDuration makes sense. In the implementation, this option seems to be "number of times to repeat the same frame.", which I in my mind is just a waste of filesize.

https://github.com/yahoo/gifshot/blob/cf0bd5fa831defa184e596b0b6df5aef9cccba94/src/modules/core/AnimatedGIF.js#L241-L246

for (let i = 0; i < frameDuration; i ++) {
gifWriter.addFrame(0, 0, width, height, frame.pixels, {
palette: framePalette,
delay: delay
});
}

Also I should dynamically set the interval option as it relates to my framerate concept, since this is the value used to determine a frames duration on screen.

https://github.com/yahoo/gifshot/blob/cf0bd5fa831defa184e596b0b6df5aef9cccba94/src/modules/core/AnimatedGIF.js#L230

It should be 1 sec / X fps. The default of 0.1 is appropraiate for 10fps. For 15fps I'll set interval to 0.066.

@chrisgervang
Copy link
Collaborator

Here is a spreadsheet of runs I've benchmarked so far. So far early findings:

  • The intermediate format does impact capture time and save time, and did not affect file size. A JPEG at 80% balances quality and performance well.
  • The diminishing returns point for number of workers was 4. 3 is also acceptable.

Still working out a FPS and sampleInterval recommendation. The retina double pixel density (doubles resolution?) effects capture and save performance, and I may recommend reducing it during rendering (is that possible?)

@ibgreen
Copy link
Collaborator Author

ibgreen commented Jun 5, 2020

I am surprised that the intermediate format has such a big impact. Since I assume the algorithm works on parsed images, I wonder if this difference happens during image parsing - or it is the fact that images with less quality/detail take less time to recompress?

@ibgreen
Copy link
Collaborator Author

ibgreen commented Jun 5, 2020

Also there are a few other GIF libraries out there that might perform better, e.g:

@ibgreen
Copy link
Collaborator Author

ibgreen commented Oct 24, 2023

Mentioning in future tracker but closing due to inactivity.

@ibgreen ibgreen closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants