Convert video to GIF
Cut the part you want with -ss and -t, then make a palette from it and apply it, in one filter. The response holds the GIF’s download URL.
The request
Request
curl https://media.logicboostkit.com/ffmpeg/process \
-H "Authorization: Basic $MEDIA_KEY" \
-H "Content-Type: application/json" \
-d '{
"task": {
"inputs": [
{
"file_path": "dir_pi23jgy1yxlmigi873bz/source.mp4",
"options": [
"-ss",
"2",
"-t",
"3"
]
}
],
"outputs": [
{
"file": "clip.gif",
"options": [
"-vf",
"fps=10,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse",
"-loop",
"0"
]
}
]
}
}'Response
HTTP/1.1 200 OK
X-Request-Id: job_0mv6io8lccjzfdcme0rft6oj
{
"ok": true,
"result": [
{
"file_name": "clip.gif",
"size_bytes": 2516582,
"download_url": "https://…"
}
],
"usage": {
"time_sec": 4.2,
"input_size_gb": 0.048828125,
"output_size_gb": 0.00234375,
"gb_sec": 0.214921873
},
"request_id": "job_0mv6io8lccjzfdcme0rft6oj",
"amount_usd": 0.002862759
}The options, explained
| -ss 2 -t 3 | On the input: three seconds from second 2. |
|---|---|
| fps=10 | Ten frames a second: smooth enough, and a smaller file than the source’s rate. |
| scale=480:-1:flags=lanczos | 480 pixels wide, proportions kept, with a sharp scaler. |
| split, palettegen, paletteuse | A GIF has 256 colours. Making the palette from the clip itself keeps its colours true. |
| -loop 0 | Loop forever. |
Variations
Smaller file
Fewer frames and fewer pixels.
In the output: "options": ["-vf", "fps=8,scale=320:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse", "-loop", "0"]Animated WebP instead
Usually much smaller than a GIF, with full colour.
In the output: "file": "clip.webp", "options": ["-vf", "fps=10,scale=480:-1", "-c:v", "libwebp_anim", "-quality", "70", "-loop", "0"]What it costs
A short GIF from a 50 MB clip: (0.05 GB + 0.012 GB) × 8 s = 0.496 GB-seconds, which is USD 0.0066 at USD 0.01332 per GB-second.