Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which video format is right for `sendVideo` method in Telegram Bot API

Which video format can be used in Telegram Bot API sendVideo method?

On the page they only mention "H.264/MPEG-4 AVC"

So if I convert a video (without sound) with

ffmpeg -i input -an -c:v libx264 -crf 26 out.m4v

I get an ok:true as response but I can't see the preview (blurred still image) in the Telegram client.

like image 416
Andy Avatar asked Aug 01 '16 15:08

Andy


People also ask

What is the video format of Telegram?

As the answer above stated: Telegram indeed uses H. 264 and MPEG-4 is a must as a container. If you upload a video file from computer, in the case the file exceeds 10 MB it will be marked as a file and will not be playable by Web app or Android app.

How can I upload my video on Telegram?

Open a chat or channel and tap on the attachment menu (paperclip icon) and you'll see a menu where you can choose what you want to upload. Here you can select photos, videos, files, etc. You can upload a video up to 1.5 GB and share it with your friends or keep it in your cloud for safe-keeping.

What API does Telegram use?

API TL-schema, as JSON.


1 Answers

This was really driving me nuts: It's important that the file extension is ".mp4". If you upload a video with ".m4v" extension you'll not see a preview window and the video is opened in an external player.

So here is my final command to reencode and resize a video and send it to the bot using curl:

ffmpeg -i input -an -c:v libx264 -crf 26 -vf scale=640:-1 out.mp4
curl -v -F chat_id=CHATID -F [email protected] -F caption=foobar https://api.telegram.org/bot<TOKEN>/sendVideo
like image 114
Andy Avatar answered Oct 19 '22 23:10

Andy