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 :
It describes as 600x473px, but real downloaded mp4 size is :
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 :))
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.
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.
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.
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.
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 .
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.
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.
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.
It seems like the only workaround atm is to convert gif to mp4 (yeah, such a frustrating experience) until the issue is fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With