Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot api : issue with GIF upload/download size

Faced with issue, when i am trying to send GIF to my bot, but bot can't access to original size of image. Seems like telegram servers converting it to mp4 (it is a good idea, looks fine) and when i trying to download it - it always looks like a thumbnail with maximum 320px of bigger side.

Looks, like it is an api bug, because for example here :

enter image description here

It describes as 600x473px, but real downloaded mp4 size is :

enter image description here

So, trying to understand - where i'm wrong here, as original gif size require for my project needs... Maybe any workaround exists here?

ps. in case of converting gif to mp4 manually with saving quality and size and then submitting to bot - it works awesome, without any additional compression and etc, but it is unacceptable to ask use do it before using bot.

update :

To reproduce (you need you bot/bot_token and also, be able to receive webhook with json) :

1) sending this gif (https://c2n.me/47Y3H37.gif) to the bot via windows 10 telegram client (v2.1.10). Using "send without compression". Gif size : 600x473, 3.35MB

2) Bot received and Telegram sending webhook :

{
  "update_id": 290360893,
  "message": {
    "message_id": 21,
    "from": {
      "id": 101483786,
      "is_bot": false,
      "first_name": "edited",
      "last_name": "edited",
      "username": "edited",
      "language_code": "en"
    },
    "chat": {
      "id": edited,
      "first_name": "edited",
      "last_name": "edited",
      "username": "edited",
      "type": "private"
    },
    "date": 1591962500,
    "animation": {
      "file_name": "9Ywn9p.gif.mp4",
      "mime_type": "video/mp4",
      "duration": 4,
      "width": 600,
      "height": 473,
      "thumb": {
        "file_id": "AAMCAgADGQEAAxVe42t2MTQQrFMyXbskwWiNkHjm3wACKwgAAtZ-GEtFrAh9bgzTOnpJm5QuAAMBAAdtAAMIgQACGgQ",
        "file_unique_id": "AQADekmblC4AAwiBAAI",
        "file_size": 15304,
        "width": 320,
        "height": 252
      },
      "file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
      "file_unique_id": "AgADKwgAAtZ-GEs",
      "file_size": 68253
    },
    "document": {
      "file_name": "9Ywn9p.gif.mp4",
      "mime_type": "video/mp4",
      "thumb": {
        "file_id": "AAMCAgADGQEAAxVe42t2MTQQrFMyXbskwWiNkHjm3wACKwgAAtZ-GEtFrAh9bgzTOnpJm5QuAAMBAAdtAAMIgQACGgQ",
        "file_unique_id": "AQADekmblC4AAwiBAAI",
        "file_size": 15304,
        "width": 320,
        "height": 252
      },
      "file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
      "file_unique_id": "AgADKwgAAtZ-GEs",
      "file_size": 68253
    }
  }
}

, so you can see there, that size is correct, but weight - no, it is only 68253 bytes = 66.65kb, instead of ~3.35MB (some less, because of converting)

3) Get File_id : CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA from this webhook and trying to use it in api by calling GET "https://api.telegram.org/bot{your_bot_token}/getFile?file_id=CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA" and you will receive :

{
  "ok": true,
  "result": {
    "file_id": "CgACAgIAAxkBAAMVXuNrdjE0EKxTMl27JMFojZB45t8AAisIAALWfhhLRawIfW4M0zoaBA",
    "file_unique_id": "AgADKwgAAtZ-GEs",
    "file_size": 68253,
    "file_path": "animations/file_12.mp4"
  }
}

4) Downloading file using this file_path : GET "https://api.telegram.org/file/bot{your_bot_token}/animations/file_12.mp4" and... getting this mp4 file : https://c2n.me/47Y4oAv.mp4 , with loss quality, weight and size (320x252)

But when you are trying to download it from Telegram client - by clicking "save as" - works fine, mp4 with appropriate size/weight. So seems like an api bug...

update#2 : tried to submit it via tfs telegram support, but also, can't login using my phone number... (https://c2n.me/47Yqswl.png). @pavel_durov, could you please fix it all :))

like image 462
Nigrimmist Avatar asked Jun 08 '20 08:06

Nigrimmist


People also ask

Can I upload gif on Telegram?

Type @gif in the message field and hit Space on your keyboard. This will bring up a pop-up menu of GIFs, and the message field will now read "Search GIFs." This way, you can quickly search and send GIFs in a chat by using the message field as a search box. Enter a search keyword.

Why bots are not working in Telegram?

Suggestions: Ensure the Bot is in the group and as an admin. Try adding a new access token (revoke existing API key and create a new one then replace in plugin settings) If you edited the bot with @BotFather, make sure to restore it to the default settings.

What API does Telegram use?

The more well-known of Telegram's APIs is its Bot API, a HTTP-based API for developers to interact with the bot platform. The Bot API allows developers to control Telegram bots, for example receiving messages and replying to other users.

How do I download a file or photo that was sent to my telegram bot?

The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. For the moment, bots can download files of up to 20MB in size.

Is there a file size limit for the telegram bot API?

Sorry, something went wrong. Telegram Bot API has a limit on the file size. Please join our group chat on Telegram if you have any questions. Sorry, something went wrong. Sign up for free to join this conversation on GitHub .

How do I report a bot in telegram?

The Telegram Bot API provides an HTTP API for creating Telegram Bots. If you’ve got any questions about bots or would like to report an issue with your bot, kindly contact us at @BotSupport in Telegram.

How do I send files to telegram?

Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content. Post the file using multipart/form-data in the usual way that files are uploaded via the browser. 10 MB max size for photos, 50 MB for other files.

What is a telegram audio file?

File size in bytes This object represents an audio file to be treated as music by the Telegram clients. Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.


1 Answers

It seems like the only workaround atm is to convert gif to mp4 (yeah, such a frustrating experience) until the issue is fixed.

like image 177
Anton Zolotukhin Avatar answered Oct 17 '22 06:10

Anton Zolotukhin