Open alphamodel opened 4 years ago
BTW, I tried to use pyrogram
to send video, and it works. I also checked code for these two functions, they are almost identical. Any idea what is going on here?
Both libraries use InputMediaUploadedDocument
to upload video with thumbnail, but telethon
does not work while pyrogram
works as expected.
If you've found how to solve the issue, please indicate what the solution is.
If the issue is not solved, please reopen it or let me know so I can reopen it.
@Lonami No, I do not find solution within telethon
. It seems no one is interested in the issue, and pyrogram
is able to provide the functionality as mentioned in the last comment, so it may be called partial solved.
Well, I am interested in solving issues within my library. Whether I have the time or interest to tackle them now is another matter.
I partially traced the code, for the case when the file is uploaded using upload_file
function, the send_file
code does not handle thumbnail at all:
Sorry, seems in the current repo the code is patched already. I have tested the current version is working as expected.
Weird thing, I'm testing both libraries with output.mp4.zip and none show the custom thumbnail in Telegram Desktop (bot
is a Telethon client, app
is a client using the other library):
desktop = pathlib.Path(...)
with bot, app:
bot.send_file('lonami', desktop / 'output.mp4', thumb=desktop / 'oh.jpg')
app.send_video('lonami', desktop / 'output.mp4', thumb=desktop / 'oh.jpg')
@Lonami Are the size or dimensions of image too large?
The file size is 26KB which I hoped would be small enough for a thumbnail used in such a large video preview but maybe it has to be even smaller. If this is the case maybe Telethon could do the resizing…
Edit: tried with a 2742 bytes JPEG file, 62x57 pixels, still doesn't work.
Maybe for file larger than 10MB, telegram will not generate thumbnail for it and use the custom one. Otherwise, telegram will use thumbnail generated by its server?
Maybe the video needs to be larger than 10MB, but that would be a very silly restriction.
this is how I had done using an old version of Telethon, but I think it still works with the newer versions.
Also, less than 10MB video thumbnails are generated by Telegram servers, and bots can't currently override it, to the best of my knowledge.
I have the same problem. my code:
async def send_correcly_media(event, files):
media = []
thumbs = []
attributes = []
nomedia = []
for f in files:
if f.endswith('.mp4'):
thumb, duration = process_video(f)
width, height = get_video_dimensions(f)
media.append(f)
thumbs.append(thumb)
attributes.append(DocumentAttributeVideo(duration=duration, w=width, h=height, supports_streaming=True))
elif f.endswith('.message'):
pass
else:
nomedia.append(f)
msg = remove_links(event.message.text)
if media:
await event.reply(msg, file=media, thumb=thumbs, attributes=attributes, supports_streaming=True)
if nomedia:
await event.reply(msg, file=nomedia)
Also all album with videos file created by Telethon works correctly on telegram-desktop but are show as single file on telgram for android :'(
If you believe the library is doing something wrong, you are welcome to try with raw API. You can also enable debug mode in official clients to learn how they do it, although I do not remember the details on how to achieve that.
the bug seems to me here: https://github.com/LonamiWebs/Telethon/blob/v1/telethon/client/uploads.py#L377
the _send_album don't support thumb, so the thumb is not sended
this problem is very relevant to this day
Still problem. I set custom thumbnail on videos while uploading, more I want to change by forwarding but I can't
I cannot get video thumbnail displayed. The code used to send out video is standard code in the manual. I tried all possible ways I can find to send the video. Following are the things I have tried:
All files are send with
supports_streaming=True
. If additional attribute is provided,supports_streaming
is also set toTrue
in the attributes. Does anyone succeed in upload video files larger than 100 MB with thumbnail?Sample thumbnail used when calling
send_file
: