Gist ad39e20ce7004353970bc6a1d163e248
✓ Published0🌍 Public
UUtopiah
Last edited Aug 15, 2022
Created on Aug 15, 2022
This example shows a shell script that automatically converts a video file into a Twitter-compatible GIF by iteratively adjusting the output size. It first attempts a direct conversion with ffmpeg, then repeatedly re-encodes while halving or scaling the width until the resulting GIF falls between 10 and 15 megabytes. The script uses ffmpeg’s filter_complex with palettegen and paletteuse to generate a optimized color palette, and employs shell arithmetic and file-size checks to converge on the target. The process relies solely on command-line tools and standard Unix utilities, with no external JavaScript or visualization libraries involved.
AI-generated description