Overview
This skill is specifically used to convert any video (such as MP4) into high-quality GIF animated sticker packs. In scenarios such as creating WeChat sticker packs, it provides a complete workflow from "coordinate calibration" to "animated image generation." It supports drawing red and yellow alternating pixel coordinate scales on screenshots (accurate to 50px), helping users precisely determine the cropping range.
Keywords: video to GIF, WeChat sticker pack, coordinate positioning, GIF speedup, frame freeze, ffmpeg
When to use this skill
- When you want to convert a video into a GIF sticker pack, but are unsure of the specific cropping coordinates.
- When you need to precisely locate the coordinates of a subject in a video and want to generate a preview image with pixel scale.
- When you need to adjust the GIF speed (such as 1.5x speed), or want the last frame of the GIF to freeze for a period of time (such as freezing for 0.4 seconds).
Directory structure
gemini-omni-video-to-sticker-gif/
├── SKILL.md
└── scripts/
└── video_to_gif.py # 核心处理脚本
Parameter description
Script video_to_gif.py accepts the following parameters:
video_path(positional parameter): absolute path of the input video file.-o,--output: output file path. If in--gridmode, the output is a PNG preview image; otherwise the output is a GIF animation.--ss: start time of the clip (for example2.5, unit is seconds, default is0.0)。-t,--duration: duration of the clip (for example3.5, unit is seconds).--to: end time of the clip (for example6.0, unit is seconds). If--tois provided, the duration will be calculated automaticallyduration = to - ss。--crop: crop region. The following two formats are supported:w:h:x:y(FFmpeg standard format, such as700:700:292:10)x,y,w,h(such as292,10,700,700orxy292x10 wh700x700format)
--scale: output size (for example600:600, default is600:600)。--speed: playback speed multiplier (for example1.5, default is1.0, greater than 1.0 means speedup, less than 1.0 means slowdown).--freeze: freeze duration of the last frame (for example0.4, unit is seconds, default is0.0, meaning no freeze).--grid: enable grid mode. When enabled, no GIF is generated; instead, a frame at--ssis extracted, and a pixel coordinate scale is overlaid on it (red lines represent 100px, yellow dashed lines represent 50px), used for precise positioning.
Usage examples
1. Extract and generate a coordinate reference image with scale
If you are unsure of the coordinates, first generate a preview frame with a coordinate grid (at the 2.0s point):
python3 <path_to_skill>/scripts/video_to_gif.py /path/to/video.mp4 --ss 2.0 --grid -o /path/to/preview_grid.png
2. Generate a 1.5x speed sticker pack without freeze
Based on the coordinates determined from the preview image x=352, y=39, w=630, h=630, clip the 2.5s - 6.0s video segment, and create a 1.5x speed sticker pack:
python3 <path_to_skill>/scripts/video_to_gif.py /path/to/video.mp4 --ss 2.5 --to 6.0 --crop 630:630:352:39 --speed 1.5 -o /path/to/output.gif
3. Generate a 1.2x speed sticker pack with the last frame frozen for 0.4 seconds
python3 <path_to_skill>/scripts/video_to_gif.py /path/to/video.mp4 --ss 2.2 --to 6.2 --crop 700:700:319:10 --speed 1.2 --freeze 0.4 -o /path/to/output_freeze.gif
Common pitfalls and notes
- Dependencies: the system must have
ffmpegandffprobeinstalled, and they must be added to the environment variables. - Crop region out of bounds: the
x + wory + hentered cannot exceed the original resolution of the video, otherwise ffmpeg will report an error. You can useffprobeto first check the original video resolution, or directly refer to the generated--gridEdge scale of the image. - WeChat sticker size limit: The size limit for custom WeChat stickers is usually 5MB (some older versions have a lower limit). If the generated GIF is too large, it is recommended to control the file size by reducing the duration, lowering the frame rate, or scaling the dimensions (for example, from 600x600 down to 300x300).