Skip to content

Instantly share code, notes, and snippets.

@kirillshevch
Last active September 21, 2024 18:35
Show Gist options
  • Save kirillshevch/572d610d43cd30c1de71a0ec4ed18f8a to your computer and use it in GitHub Desktop.
Save kirillshevch/572d610d43cd30c1de71a0ec4ed18f8a to your computer and use it in GitHub Desktop.
How to convert video into Telegram Animated Sticker with FFmpeg (WEBM)

How to convert video into Telegram Animated Sticker with FFmpeg (WEBM)

ffmpeg -y -i input.mov -r 30 -t 2.99 -an -c:v libvpx-vp9 -pix_fmt yuva420p -vf 'scale=512:512:force_original_aspect_ratio=decrease' output.webm

Here is a breakdown of the options:

-y - Overwrite the output file if it already exists.

-i input.mov - Specifies the input file, in this case, animated_sticker.mov.

-r 30 - Sets the output video frame rate to 30 frames per second (fps).

-t 2.99 - Sets the duration of the output video to 2.99 seconds.

-an- Excludes audio from the output video (no audio stream in the output).

-c:v libvpx-vp9 - Sets the video codec to VP9 (libvpx-vp9) for the output video.

-pix_fmt yuva420p - Sets the pixel format of the output video to YUV420p with an alpha channel (transparency).

-vf 'scale=512:512:force_original_aspect_ratio=decrease' - Applies a video filter that scales the video to a maximum size of 512x512 pixels while preserving the original aspect ratio.

-b:v 400K - Sets the target video bitrate to 400 Kbps (Kilobits per second).

output.webm - Specifies the output file name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment