Requirements for Telegram emojis:
- Video must be exactly 100x100 pixels in size
- Video duration must not exceed 3 seconds.
- Frame rate can be up to 30 FPS.
- Video should be looped for optimal user experience.
- Video size should not exceed 64 KB.
- Video must be in .WEBM format encoded with the VP9 codec.
- Video must have no audio stream.
Step 1
Converting .tgs to .webm:
docker run --rm -e HEIGHT=100 -e WIDTH=100 -e FPS=30 -e -v <INPUT_FOLDER>:/source edasriyan/lottie-to-webm
Step 2 (Optional)
Compressing WEBM file:
ffmpeg -c:v libvpx-vp9 -i <INPUT>.webm -c:v libvpx-vp9 -crf <CRF> -b:v 0 -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" -c:a copy HeaertInRedFlame-compressed.tgs.webm
Where CRF is customizable parameter. Standard CRF is about 30. When CRF < 30, file size is larger. When CRF > 30, file size is lesser. CRF is not FPS!
Additionally
Additional parameter to speed up:
-filter:v "setpts=0.5*PTS" - speeds up by 2 times.
-filter:v "setpts=0.9*PTS" - speeds up by 9/10 times.
Example:
ffmpeg -c:v libvpx-vp9 -i <INPUT>.webm -filter:v "setpts=0.5*PTS" -c:v libvpx-vp9 -crf <CRF> -b:v 0 -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" -c:a copy HeaertInRedFlame-compressed.tgs.webm