question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to render / release directly to mp4 or gif, plus how to make a better gif with gifsky

See original GitHub issue

I’m excited there is an easy way to render directly to mp4!

At first, I got stuck with the following error:

▶ coldtype sources/04-coldtype/bigger-loop.coldtype.py
    >>> watching... sources/04-coldtype/bigger-loop.coldtype.py
DEFAULT RENDER ACTION
> ffmpeg
writing mp4...
[image2 @ 0x7ff6d080b400] Could find no file with path '/Users/stephennixon/type-repos/shantell-sans/sources/04-coldtype/renders/bigger-loop.coldtype/scratch/scratch_%4d.png' and index in the range 0-4
/Users/stephennixon/type-repos/shantell-sans/sources/04-coldtype/renders/bigger-loop.coldtype/scratch/scratch_%4d.png: No such file or directory
...done
The file /Users/stephennixon/type-repos/shantell-sans/sources/04-coldtype/renders/bigger-loop.coldtype does not exist.

…even though I do have ffmpeg installed.

However, I eventually tried hitting a first to let the frames render, and then hitting r to make an mp4, and… it works!

https://user-images.githubusercontent.com/45946693/183216667-ad7c20be-3203-4e93-8971-89e9d196e778.mp4

So, I guess my point of filing this issue is:

  1. Documenting it in case some searches
  2. Documenting it so that perhaps there could be a simpler error message, or better yet, perhaps a step to auto render frames if needed, then render the mp4, all with one r button press
  3. Learn if I was doing something wrong! This is usually the case. 😅

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
stensoncommented, Aug 6, 2022

Interesting! The a then r thing is definitely because, back when I was making lots of lyric videos, I was really only viewing the frames in an NLE, so the r step was all part of Premiere or something like that. Definitely makes sense that you’d want to do both though, and I’ll admit I’ve shifted away from using NLE’s for shorter videos as well. There is a keyboard shortcut (routed internally to KeyboardShortcut.RenderAllAndRelease in the keyboard.py source) that will do both a render & a release at once (the keyboard shortcut is shift+cmd+a), but that (like so much else) needs to be documented.

I’ll also admit I don’t regularly make gifs, so I haven’t seen that funky color issue, though I did just replicate it on my setup. Pretty weird! I looked at the drawbot source and it looks like they use gifsicle internally. I tried that but had some trouble with it on the command line, though looks like gifski is another option, which does work. So one option for a better gif export would be to roll a gifski wrapper and call it from a custom release function, like this (would require a brew install gifski if you don’t have it):

from coldtype import *

@animation((600, 250), timeline=30, bg=hsl(0.7), render_bg=1)
def scratch(f):
    return (StSt("COLD", Font.ColdObvi(), 200
        , wdth=f.e("eeio"))
        .align(f.a.r)
        .f(1))

def gifski(a:animation, passes):
    from subprocess import run
    root = a.pass_path(f"%4d.{a.fmt}").parent.parent
    gif = root / (a.name + ".gif")
    run(["gifski", "--fps", str(a.timeline.fps), "-o", gif, *[p.output_path for p in passes if p.render == a]])

def release(passes):
    gifski(scratch, passes)

Will work on a better error message regardless!

0reactions
stensoncommented, Aug 7, 2022

ah nice note on -W — just added that to a little generic gifski wrapper made available in coldtype.renderable.animation (added an example to the repo here https://github.com/coldtype/coldtype/blob/main/examples/animations/transparent_gifski.py)

also added a better error message for the original issue, which will be released with 0.9.7 very shortly — will close for now, thanks for reporting!

Read more comments on GitHub >

github_iconTop Results From Across the Web

gifski — highest-quality GIF converter
gifski converts video frames to GIF animations using pngquant's fancy features for efficient cross-frame palettes and temporal dithering. It produces animated ...
Read more >
gifski: Highest Quality GIF Encoder
Gifski converts image frames to high quality GIF animations. Either provide input png files, or automatically render animated graphics from the R graphics ......
Read more >
ImageOptim/gifski: GIF encoder based on ... - GitHub
Highest-quality GIF encoder based on pngquant. gifski converts video frames to GIF animations using pngquant's fancy features for efficient cross-frame ...
Read more >
Converting Video to GIF: How to Use Photoshop and GIF ...
Is there a way to create your own GIF? Is it possible to convert a video to GIF? YES! Video to GIF Using...
Read more >
In gifski: Highest Quality GIF Encoder - Rdrr.io
Gifski converts image frames to high quality GIF animations. Either provide input png files, or automatically render animated graphics from the R graphics ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found