Skip to content

Commit

Permalink
fix: updating gif maker post
Browse files Browse the repository at this point in the history
  • Loading branch information
shivan-s committed May 3, 2024
1 parent 30bda60 commit 45e2962
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion content/posts/programming/screencasts-to-gifs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ Sometimes I want to show my screencasts, but the site I want to showcase them do
Now, it comes in handy to be able to turn `.mov` files into animated `.gif`s

Requirements:

- palettegen
- ffmpeg

The shell file `makegif.sh` or whatever you want to name it:

```sh
#!/bin/bash
cd $PWD
Expand All @@ -43,4 +45,24 @@ The above shell script needs to be in the same folder as the `.mov` files that y

The script creates a new directory `gifs/`, which contain the newly created animated `.gif` files.

*I'll add more to this*
The crux of this is handled by `ffmpeg` which is a powerful library for dealing with movie file encodings.

A problem we face with converting the `.mov` file into a `.gif` is colours. `.gif` files only support 256 colours, while `.mov` files have a lot more colours. Fortunately, for screencasts, but all colours are used, so we can create a palette of most comment colours that are used. And we do this with `pallettegen`. This palette is fed into ffmpeg to construct our `.gif` in almost exact replication to the `.mov` file.

## Update

In the above shell script, I had to move the files into a speific folder and then run this command. It got extremely cumbersome to have move files around in order to turn them into gifs. I also wanted the option of using a command line tool to turn a selected file into a gif. For examples `makegif test.mov`.

Hence, I started [working on `makegif`](https://github.com/shivan-s/makegif). I decided to use Golang because it's easy to delivery a binary to work as a CLI (command line interface). It's essentially glues together multiple projects:

- [Cobra](https://github.com/spf13/cobra) - helps create CLIs
- [ffmpeg-go](https://github.com/u2takey/ffmpeg-go) - a wrapper for ffmpeg and palletegen

The package can be installed if the user has Golang installed.

```bash
go install github.com/shivan-s/makegif

```

Now it can be used as a normal CLI tool. The plan in future is to make this installable via `brew`.

0 comments on commit 45e2962

Please sign in to comment.