Telegrambots: SendVideo class sends only thumbnail instead of video

I'm working on a scheduler bot in telegram, which sends scheduled messages automatically. I'm using rubenlagus Telegrambots package. I'm experiencing weird behavior with the SendVideo class, where it just sends an image of the Thumbnail instead of the whole video.

I save the videos sent to my bot by using this method:

private String saveVideoToFile(String filePath, String ID) {

    try {
        String pathString = "Videos/" + ID + ".mp4";
        File file = new File(pathString);
        file.createNewFile();
        downloadFile(filePath, file);

        return pathString;
    } catch (TelegramApiException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

I then save the pathString to videoFilePathvand send the message with the video by using this method:

public boolean sendMessageContent(TelegramLongPollingBot bot, List<String> receivingChatsSet) {
    SendVideo sendVideo = new SendVideo();
    sendVideo.setCaption(message);
    sendVideo.setCaptionEntities(messageEntities);
    File file = new File(videoFilePath);
    if(!file.exists()) {
        System.out.println("!!ERROR!! Image File not Found! Path: " + videoFilePath);
        return false;
    }
    InputFile inputFile = new InputFile();
    inputFile.setMedia(file);
    sendVideo.setVideo(inputFile);
    for (int i = 0; i < receivingChatsSet.size(); i++) {
        boolean sent = false;
        for (int j = 0; j < 5; j++) {
            try {
                sendVideo.setChatId(receivingChatsSet.get(i));
                bot.execute(sendVideo);
                sent = true;
                break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (!sent)
            return false;
    }
    return true;
}

What makes this even weirder is that it sends the message with the video as expected when the sending happens during the same session the video was received / same session the mp4 was saved to the file. But after I restart the program and read in my saved data ("videoFilePath" etc.) it then only sends the thumbnail, not the whole video. I cant really explain this behaviour as in both cases the mp4 get loaded from a file when sending it.

The saved videos seem to be saved correctly as I can play them using a video player.

Thank you for your help:)

Additional Information:

Here we can see the bot saving and correctly sending the video message during the same session. Bot bahaviour during same session

Here we can see how after a restart the bot now only sends an image instead of the whole video. enter image description here

1 answer

  • answered 2021-10-12 16:00 McPringle

    The standard behavior for sending images, videos, and more via Telegram (and similar applications) is to just send a thumbnail/preview. If the receiver opens the message, the complete image or video will be sent. This prevents spamming and sending unnecessary data.

    E.g. the receiver is on mobile data. He has limited traffic. To prevent people and bots from sending huge videos and create a high bill for the receiver, this is the way to go. The receiver can decide to download the video later, when he has WiFi.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum