Code Monkey home page Code Monkey logo

Comments (13)

ku1ik avatar ku1ik commented on August 23, 2024 4

I've generated gif from the asciicast linked by @ahmetb using latest (today's) version, with this command:

asciicast2gif -S 1 https://asciinema.org/a/dD9UhCIaPw13znirhmGUnNJtd.cast ahmetb.gif

Or Docker version:

docker run --rm -v $PWD:/data asciinema/asciicast2gif -S 1 https://asciinema.org/a/dD9UhCIaPw13znirhmGUnNJtd.cast ahmetb.gif

The resulting gif is 213kb, which is a good improvement over initial 964kb.

ahmetb

from asciicast2gif.

tianon avatar tianon commented on August 23, 2024 3

Heh, I don't use GNOME -- I actually ran it inside a Docker container, and had a small wrapper script to grab the proper X, Y, width, and height for capturing the window I was interested in. It doesn't need more than the X11 socket in order to work. 👍

from asciicast2gif.

publicarray avatar publicarray commented on August 23, 2024 3

I've played a little with ImageMagick and gifsicle

Command Size (KB) Savings (KB)
asciicast2gif 'https://asciinema.org/a/dD9UhCIaPw13znirhmGUnNJtd.cast?dl=true' out.gif 941 0
asciicast2gif 'https://asciinema.org/a/dD9UhCIaPw13znirhmGUnNJtd.cast?dl=true' out.gif -S 1 * 348 593
gifsicle --optimize -O3 --colors 16 -o out-16.gif out.gif 336 593+12
convert out.gif -coalesce -layers RemoveDups -layers RemoveZero -layers OptimizeFrame out-dedupe.gif 321 593+27
convert out.gif -coalesce -layers RemoveDups -layers RemoveZero -layers OptimizeFrame - | gifsicle --optimize -O3 -o out-dedupe-gifsicle.gif 259 593+89
convert out.gif -coalesce -layers RemoveDups -layers RemoveZero -layers OptimizeFrame - | gifsicle --optimize -O3 --colors 16 -o out-dedupe-16.gif 253 593+95
convert out.gif -coalesce -layers RemoveDups -layers RemoveZero -layers OptimizeFrame - | gifsicle --optimize -O3 --colors 6 --use-colormap=gray -o out-dedupe-bw.gif 175 593+173

* The scaled=1 gif is used as an input for all remaining commands

from asciicast2gif.

publicarray avatar publicarray commented on August 23, 2024

There are many factors to the file size. The example.gif is only 497×290 pixels, uses few colours, is short (~28 seconds) and has a low area of change between frames (easier to compress).

asciicast2gif already uses gifsicle to compress the output gif, but there are more options from gifsicle that you can try.

BTW the -S option in asciicast2gif is for up-scaling, you probably want to set it to 1.

from asciicast2gif.

publicarray avatar publicarray commented on August 23, 2024

You can also ask @tianon how the gif was generated.

from asciicast2gif.

tianon avatar tianon commented on August 23, 2024

Was a pretty standard byzanz (https://github.com/GNOME/byzanz) recording -- nothing very custom there.

from asciicast2gif.

publicarray avatar publicarray commented on August 23, 2024

Thanks for chiming in. Cool project for GNOME users.

from asciicast2gif.

ku1ik avatar ku1ik commented on August 23, 2024

@ahmetb can you give us a link to your recording which ends up being 964kb gif? We can play with various arguments for asciicast2gif and for gifsicle.

from asciicast2gif.

ahmetb avatar ahmetb commented on August 23, 2024

https://asciinema.org/a/dD9UhCIaPw13znirhmGUnNJtd

from asciicast2gif.

ku1ik avatar ku1ik commented on August 23, 2024

@publicarray awesome! That's very helpful.

Another things to try:

  • check out giflossy instead of gifsicle (see #1)
  • use gifsicle to assemble frames instead of ImageMagick (see #3)

I'm thinking that maybe asciicast2gif could have a concept of "presets", probably 3 (low, normal, high) would be enough to cover everyone's needs. But before presets, I'd like to try the above.

from asciicast2gif.

ahmetb avatar ahmetb commented on August 23, 2024

It'd be really cool to script these into a separate tool, or bundle in the asciicast2gif tool?

from asciicast2gif.

ku1ik avatar ku1ik commented on August 23, 2024

I've implemented some optimizations:

  • the biggest impact on filesize was too high frame-rate - it's capped at 15fps now
  • added support for giflossy (if giflossy is installed instead of gifsicle the options passed to gifsicle command are extended with -lossy=80)

I've pushed new version to npm, and there's new image on Docker hub (docker pull asciinema/asciicast2gif if you previously pulled it).

You can set GIFSICLE_OPTS env var to override the options passed to gifsicle, which is great for experimenting with different color/optimization/lossyiness combinations.

from asciicast2gif.

ahmetb avatar ahmetb commented on August 23, 2024

Thanks a bunch, that's a pretty good improvement!

from asciicast2gif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.