36 lines
1.6 KiB
Markdown
36 lines
1.6 KiB
Markdown
# Golang FFMPEG Animation Package
|
|
|
|
This package creates an image that can be drawn on, and provides an `EmitFrame()` method to pipe the image to [FFMPEG](https://ffmpeg.org/), and a `Close()` method to finish the animation.
|
|
|
|
The process of actually drawing frames of animation is left as an exercise for the reader.
|
|
|
|
The extension of the destination file determines the encoding format and parameters:
|
|
|
|
- `.gif`: Creates a looping indexed GIF animation.
|
|
|
|
Generating an optimal palette would require buffering the entire animation, so instead a fixed general purpose palette is used.
|
|
- `.png`/`.apng`: Creates a looping animated PNG image. Lossless and supports transparency.
|
|
|
|
This is the only supported format that is both completely lossless and supports transparency.
|
|
- `.mp4`: Creates an MP4 video using the `libx264rgb` codec with the `ultrafast` preset. Should be lossless, but doesn't support transparency.
|
|
|
|
The file will be quite large, and probably isn't something you'd want to distribute directly.
|
|
- `.mkv`: Identical to MP4, except with a Matroska container.
|
|
- `.webp`: Creates a looping WEBP animation. The RGB->YUV conversion is lossy, but is otherwise lossless and supports transparency.
|
|
- `.webm`: Creates a WEBM video. The RGB->YUV conversion is lossy, but is otherwise lossless and supports transparency.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
go get smariot.com/animate
|
|
```
|
|
|
|
## Documentation
|
|
|
|
You can find the documentation at https://pkg.go.dev/smariot.com/animate.
|
|
|
|
## Demo
|
|
|
|
The `cmd/demo` directory contains a simple program to demonstrate this package by generating the following image:
|
|
|
|
 |