TelegramBots / Telegram.Bot

.NET Client for Telegram Bot API
https://telegrambots.github.io/book
MIT License
3.22k stars 691 forks source link

How to set thumbnail when using sendvideo method #50

Closed Mohammad-Saheb closed 8 years ago

Mohammad-Saheb commented 9 years ago

Hi How can I set thumbnail when using sendvideo method ? byte[] videoDate; using (var wc = new WebClient()) videoDate = wc.DownloadData(videoUrl);

var response = await _api.SendVideo(update.Message.Chat.Id, new FileToSend(videoUrl, new MemoryStream(videoDate)), 15, myBotAdMsg, 0, new ReplyKeyboardMarkup { Keyboard = _nextVideoCommands, OneTimeKeyboard = true, ResizeKeyboard = true });

http://oi60.tinypic.com/33ml5pj.jpg

Also response.video.thumb is null !!?

Thanks .

MrRoundRobin commented 8 years ago

Sorry for the delayed answer but i think there is no way to specify the thumbnail manually:

https://core.telegram.org/bots/api#sendvideo

or am i missing something?

Mohammad-Saheb commented 8 years ago

I think so but some bots can do it. https://telegram.me/justvideobot

Thanks

msrahmanian commented 8 years ago

Hello Sorry to ask, Did you find any way for video thumbnail in SendVideo method ?

abadakhshan commented 8 years ago

hi Someone has found an answer to this problem?

ahmadi173 commented 8 years ago

hi mohammad. i think you are sending video in wrong type. if you send video mpeg(you can see right types in telegram bot documentation) telegram will recognize sending data as video and it will show thumbnail in telegram app. :-)

Mohammad-Saheb commented 8 years ago

Hi I contacted Telegram and their response

Hi, currently api doesn't support sending thumbnails with videos. Telegram

evolves quickly and new features are added every month but we can't promise anything or give an exact timeframe.

Thanks.

On Sun, Jan 17, 2016 at 10:56 AM, mohammad ahmady notifications@github.com wrote:

hi mohammad. i think you are sending video in wrong type. if you send video mpeg(you can see right types in telegram bot documentation) telegram will recognize sending data as video and it will show thumbnail in telegram app. :-)

— Reply to this email directly or view it on GitHub https://github.com/MrRoundRobin/telegram.bot/issues/50#issuecomment-172298268 .

ahmadi173 commented 8 years ago

i think they didn't get you. because i did this long time ago.

Mohammad-Saheb commented 8 years ago

Maybe but I think my question was clear enough as well as response. Please if possible share your experience. Sample video file for test sendVideo.mp4 http://fs2.filegir.com/test/178.252.189.93/sendVideo.mp4

On Sun, Jan 17, 2016 at 11:24 AM, mohammad ahmady notifications@github.com wrote:

i think they didn't get you. because i did this long time ago.

— Reply to this email directly or view it on GitHub https://github.com/MrRoundRobin/telegram.bot/issues/50#issuecomment-172299018 .

Mohammad-Saheb commented 8 years ago

Hi The latest version of the API now supports video thumbnail automatically. Thanks

masoudkazemi commented 8 years ago

Hi I'm wondering do you test videos with sizes near to limit (50MB), because I upload a lot of videos and just those with size less than 10MB(almost) has thumbnail. and others with higher sizes no thumbnail. My videos are mainly mp4 format. what about you?

ehsanecc commented 7 years ago

I'm wondering do you test videos with sizes near to limit (50MB), because I upload a lot of videos and just those with size less than 10MB(almost) has thumbnail. and others with higher sizes no thumbnail. My videos are mainly mp4 format.

I have exactly same problem.

Coderwill commented 7 years ago

i want also send video on telegram bot but how can do that i have no idea. any one please tell me how can do that. here i have try like this=>

` WebClient webClient = new WebClient();

imageData = webClient.DownloadData(MediaPath + ds.Tables[0].Rows[i]["Url"].ToString()); MemoryStream ms = new MemoryStream(imageData);`

Bot.SendVideoAsync("@abc2017", new FileToSend(ds.Tables[0].Rows[i]["Url"].ToString(), ms), 15, sb.ToString(), replyMarkup: ReplyMarkup);

but here i have no idea how can add size of the video. here i have add size approximately for that video. please tell me how can do that.

Coderwill commented 7 years ago

also any limit of the size of video send on telegram bot please let me know i need that.

poulad commented 7 years ago

@Coderwill Please read tg docs. This is for questions about only the .NET Client of it https://core.telegram.org/bots/api#sending-files

Coderwill commented 7 years ago

@pouladpld i also visit this link and also visit api doc for the telegram bot and using this link i have make this code but i can't getting success for the send video on telegram bot. and i can't find any example for that. just i look code on this link so can you please give me some hint where is my mistake in my code.

Coderwill commented 7 years ago

@Mohammad-Saheb can you please give me some hint and help me if possible then

poulad commented 7 years ago

@Coderwill here are 2 examples of sending videos in our tests:

https://github.com/TelegramBots/telegram.bot/blob/develop/test/Telegram.Bot.Tests.Integ/SendingMessages/MultimediaMessageTests.cs#L52-L106

Coderwill commented 7 years ago

@pouladpld thanks for your replay and give me same example.

Coderwill commented 7 years ago

@pouladpld can you please give me some hint on this upload muliple videos on same time on telegram bot using c#. i have go 10+ videos send on the bot at a same time in the for loop so that time 2 or 3 videos send successfully and after utility automatically stop. do you know why this type accure with this code. i have not getting any error but my all the videos is not go there just some videos go there.

` public async Task SendCasesOnTelegramBot() {
DataSet ds = DataAccess.ExecuteDataset(Setting.ConnectionString(), "GetPostForTelegramBot"); if (ds != null && ds.Tables.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string VideoUrl = null; VideoUrl = CaseMediaPath + ds.Tables[0].Rows[i]["Url"].ToString();
var sb = new StringBuilder(); sb.Append("abc");

        await Bot.SendVideoAsync("@abc", video: VideoUrl, caption: sb.ToString(), replyMarkup: ReplyMarkup); 

           await Task.Delay(18000);          
    }
}

}`

this my code please see and help me i am facing issue on this task.

poulad commented 7 years ago

@Coderwill code looks OK. Probably tg limits the traffic. Try asking that from @BotSupport on tg.

Coderwill commented 7 years ago

@pouladpld Thnak you so much for your response.

poulad commented 7 years ago

@Coderwill If you found your answer, post it here please. I've faced such issue before and assumed it has to do with tg's rate limiting.

Coderwill commented 7 years ago

@pouladpld can you please explain little bit more what you say exactaly in your word.on this sentance for "assumed it has to do with tg's rate limiting."

Coderwill commented 7 years ago

@pouladpld i want to some need suggestion related telegram bot . i need to create chat module on the bot. for ex. i have one bot name of "Abc".so i want to first show some list of show user in the bot and i have select one user then that time chating will start in the bot. so it's possible with c#?

poulad commented 7 years ago

@Coderwill this is not the place to discuss that. Try asking that in our group on tg: @tgbots_dotnet

Coderwill commented 7 years ago

@pouladpld i have join your group so can i ask any thing on that group realted on .net with c#?

dmakhkamov commented 6 years ago

I also have the same issue with the size. Whenever i send video less than 10Mb in size, thumb is fine. Whenever i send a larger file, thumb is gone Please advise

karb0f0s commented 6 years ago

@dmakhkamov please join our channel TelegramBots - .NET and ask questions there. As of your question — if this behaviour is specific for Telegram.Bot .Net library please open issue and provide relevant code example. Otherwise this question is designated to official Telegram @botsupport .

gloschtla commented 5 years ago

If you take UploadBot, you can upload a thumbnail picture, before sending the video URL to the bot. If the video source is online, I usually extract the temporary download link through sfrom.net - This download link you send to @uploadbot followed by |filename.mp4

PystoyPlayer commented 9 months ago

python:

with open(input_file, "rb") as video:
    response = requests.post(url,
        data={"chat_id": chat_id, "supports_streaming": True, "caption": comment},
        files={"video": video, "thumbnail": open(preview_path, 'rb')},
        params={"parse_mode": 'MarkdownV2', "width": video_width, "height": video_height, "duration": video_duration, "disable_notification": disable_notification})

thumb must be less than 200KB and 320px