Tool for converting gif to WebM video for Telegram Video Sticker
This tool also supports non-GIF files(mp4, apng...) despite its name, but it's optimized for converting small-short videos.
- Download gif2tgsticker.exe from releases.
- Download FFmpeg binaries, put ffmpeg.exe and ffprobe.exe in same directory.
- For WebP conversion install ImageMagick
Easiest way for install FFmpeg on Windows 11 is by:
winget install ffmpeg
I won't provide pre-compiled executable, install dependencies yourself.
- ffmpeg
- ImageMagick(for WebP to APNG Conversion)
- Python
- Poetry
poetry install
poetry run python gif2tgsticker.py
Telegram supports up to 30 FPS.
Note that Video Stickers have 256KB file size limit, lowering framerate can help for fitting.
Since Telegram requires video to have 512px on one side, it tries to adjust it.
- Fit: Scale up/down with keep aspect ratio
- Landscape video will have 512px width, height will be resized within aspect ratio.
- Vertical video will have 512px height, width will be resized within aspect ratio.
- Pad: Add transparent padding
- Landscape video will have left, right padding.
- Vertical video will have top, bottom padding.
- Scale: force to specific resolution.
Telegram Video Sticker have 3 seconds duration limit.
If the video is longer than 3 seconds, this tool will try to fit this duration by speeding up playback.
If this tool is unable to get playback duration from file, this value will be used as PTS(Presentation Time Stamp) modifier.
- 1.0 means 1x playback speed
- 0.5 means 2x playback speed
You can adjust quality of result with this value. Try changing when size of result is >= 256kb
Read FFmpeg document for more information.
poetry install
poetry shell
pyinstaller gif2tgsticker.spec