NickeManarin / ScreenToGif

🎬 ScreenToGif allows you to record a selected area of your screen, edit and save it as a gif or video.
http://www.screentogif.com
Microsoft Public License
23.88k stars 2.19k forks source link

Encoders and file size #115

Open druellan opened 7 years ago

druellan commented 7 years ago

Hi! I'm trying to understand how the different encoders work. But so far I'm not getting the results I expected.

I'm using a somehow complex GIF as a test:

abstract02

This GIF was exported from Photoshop and it's about 2mb in size. Saving the GIF from the 2.6 editor without modifications and using several encoders, I get this results:

Encoder GIF size
Photoshop 2.082 MB
System 3.963 MB
1.0 - quality 1 6.773 MB
1.0 - quality 20 6.773 MB
1.0 - quality 10 - unchanged pixels 6.740 MB
1.0 - quality 10 - unchanged - dummy color 5.372 MB
2.0 - 250 colors 6.803 MB
2.0 - 250 colors - unchanged 6.772 MB
2.0 - 250 colors - unchanged - dummy color 5.384 MB

I wasn't expecting better results than Photoshop, but twice the size as the best result, seems odd. Are those results correct?

All the files can be downloaded from: https://www.dropbox.com/s/yjnm6um1resgjbr/abstract02.zip?dl=0

Thanks!

NickeManarin commented 7 years ago

Yeah, that's it.

Photoshop is a 27 years old professional (thus very expensive) software (probably) made by several full-time developers using a very powerful language (C/C++).

ScreenToGif is a 2 years old indie (free, no ads) software made (during weekends) by 1 developer using a little bit slower managed language (C#).

Also, image encoding algorithms are quite hard for me. Specially color quantization, something that Photoshop is way better.

If you know someone up to the challenge to help me out improving the encoding algorithms, just say the word. :)

druellan commented 7 years ago

Hi @NickeManarin thanks for the answer.

I'm by no means implying you did a bad job or that your (free) work should be at the same level as an expensive professional tool. I'm just puzzled about the results here, wondering if there is some kind of bug, but anyway, your algorithms seems to work well if you are using the tool for screen capture, so...

NickeManarin commented 7 years ago

Oh, it's alright :D

From what I understand, with more colors and more color changes, the gif tends to be bigger.

I don't have Photoshop installed, but I once saw that you can add dithering and change how the type of palette. This could greatly decrease the file size.

I'll take a look at your examples to see how they behave.

ronosaurus commented 7 years ago

Nicke, are you able to incorporate existing libraries like these:

On-line example:

NickeManarin commented 7 years ago

I'm currently working on a new "Recorder" experience, I should focus on this afterwards. Thanks.

Kristinita commented 6 years ago

1. Summary

GIF's have very big size for me.

If I insert ScreenToGIF GIF to web page → user browser will hangs.

2. Example

ScreenToGIF 2.12.1.

Project file.

15-second GIF size:

But video have normal size:

3. Not helped

Yes, I can use image optimizers, but they slightly reduce GIF size.

Thanks.

vatterspun commented 6 years ago

I'm by no means implying you did a bad job or that your (free) work should be at the same level as an expensive professional tool.

Yeah man, you're doing an amazing job. I've stepped away from some of the animation stuff I was doing years ago but if I had more time I'd be all over this program.

Saving the GIF from the 2.6 editor without modifications and using several encoders, I get this results

There are a few ways to optimize GIFs that I've seen:

  1. Cut out things (colors, frames, detail, etc), which you've sort of already addressed.

  2. Analysis between frames of what hasn't changed. It's a very dumb version of what modern video players do. If you were to rip apart the Photoshop GIF file, you'd probably see huge swaths of the image missing from frame to frame.

In messing around with the format, I've seen that some GIF encoders are better than others at this, but I'm not sure of the current status. However, with the 256 color limitation, I've been arguing that animated PNG (#129) is more worth your time and effort, since there are at host of great PNG compression tools out there that could be put to the task. You might find something more interesting than the black box of "Photoshop does it somehow".

NickeManarin commented 6 years ago

Gifski — I have a bug.

@Kristinita I'll investigate that issue.

NickeManarin commented 6 years ago

@vatterspun

[...] I've been arguing that animated PNG (#129) is more worth your time and effort [...]

Indeed. I just wished that all major browsers had support for it. I'm looking at you, Edge/IE.

Anyway, with the next release (v2.14), I want to implement a "Save as PSD". Let's see if it's easy to do that and if it's possible to export with the timestamps.

druellan commented 6 years ago

ffmpeg mp4 — 2.1 MB.

If you're converting from video files, chances are the GIF encoder is not going to do a great job.

First, is not possible to compete with a lossy algorithm, but also, the "noise" the mp4 algorithm introduces into the video kills the GIF compression. GIF compression usually works detecting unchanged pixels frame to frame, a frame with mp4 "noise" is going to be vastly different to the next one, even if we can't perceive the variations, GIF compressors usually can, and that increases the file size even more.

vatterspun commented 6 years ago

Indeed. I just wished that all major browsers had support for it. I'm looking at you, Edge/IE.

I'd say it's just a matter of time. They're really down to browser customers that are either companies or people who don't mess with anything that isn't already installed on their computer. As such I'd think they'll do that to keep pace.

Frankly, support of the format by an easy-to-use and mature animation editor like yours goes much further toward broad adoption than the various posts I've done around the web.

Kristinita commented 5 years ago

Type: Questions

@NickeManarin,

1. APNG

Have you tried implemented APNG Assembler? Its developers write about it:

Creates highly optimized APNG files, uses lots of tricks to make them as small as possible

2. FFmpeg

Have you tried implemented optimize GIFs with FFmpeg as in this article?

So we needed to crunch the gifs down to the smallest possible size

Thanks.

vatterspun commented 5 years ago

Indeed. I just wished that all major browsers had support for it. I'm looking at you, Edge/IE.

I'd say it's just a matter of time.

Looks like that ended up being accurate: https://www.theverge.com/2018/12/4/18125238/microsoft-chrome-browser-windows-10-edge-chromium ... It looks like the next Microsoft web browser will support APNG along with all other Chrome-based browsers. And Internet Explorer already has very low usage numbers (I'm seeing 2.55% from statista.com as of Dec '18)