skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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
    

  2. Try adding -pix_fmt yuv420p, that made it work for me.

    Note: taken from a comment from @Pastafarianist in this same question, which should be an answer instead.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search