Hey everyone, I’m trying to figure out which video formats are compatible with the sendVideo function in the Telegram Bot API. The docs only mention H.264/MPEG-4 AVC, but I’m not sure if that’s the only option.
I tried converting a silent video using ffmpeg with this command:
ffmpeg -i original.mp4 -an -c:v libx264 -crf 24 output.mp4
The API responds with ok:true
, but there’s no preview (the blurry thumbnail) in the Telegram app. Am I missing something? Has anyone successfully sent videos with previews using this method? Any tips or tricks would be super helpful!
Also, are there any file size or duration limits I should be aware of? Thanks in advance for any insights!
I’ve had my fair share of struggles with Telegram’s sendVideo function. One thing I’ve found that works well is using the .mov format. It seems to play nicely with Telegram’s system and often generates better previews.
For file size, I typically aim to keep videos under 15MB. This isn’t an official limit, but I’ve noticed faster upload times and fewer issues at this size. As for duration, I try to keep videos under 2 minutes. Longer videos tend to have more problems with processing and playback.
Regarding your ffmpeg command, you might want to try adding the ‘-movflags faststart’ option. This can help with generating previews. Also, ensuring your video has an audio track, even if it’s silent, sometimes helps with preview generation.
Remember, Telegram’s video processing can be a bit finicky. What works one day might not work the next, so it’s always good to have a few different approaches in your toolkit.
I’ve worked extensively with the Telegram Bot API for video uploads. In my experience, MP4 using the H.264 codec is the most reliable format. For the preview issue, it is important to ensure the video contains at least one keyframe, which you can enforce by adding ‘-g 1’ to your ffmpeg command. While Telegram allows up to 50MB for bots, keeping the file size around 20MB or less tends to work better. Additionally, videos lasting about 3 to 5 minutes have proven to be most effective. These practices have consistently produced good results in my projects.
hey bob, i’ve used mp4 and webm successfully. for previews, try adding -vf scale=320:-1 to ur ffmpeg command. it’ll resize the video and might help with thumbnails. as for limits, i think it’s 50MB max. hope this helps!