Blog and knowledge base of the service

Sending a video message in a Telegram bot

A video message in Telegram is a method of sending video content to chats, groups, and channels. Unlike video notes (`sendVideoNote`), this format supports an arbitrary aspect ratio. (16:9, 9:16), long videos and complex design: captions with markup, interactive buttons and custom thumbnails. Telegram optimizes the video for smooth playback, but use sendDocument to maintain the original quality.

Sending a video message in a Telegram bot

What formats does Telegram accept videos and what are the limitations?

Telegram supports the following video formats

Horizontal(16:9), Vertical(9:16) and square(1:1)

Some limitations to consider when working with Telegram videos:

  1. The file size. The maximum size of the uploaded video is 2 GB. Vertical videos often take up less space because their duration is usually shorter, which makes downloading easier. Horizontal and square videos may require additional optimization.
  2. Auto-playback and previews. Telegram automatically plays videos without sound in feeds and chats. Vertical and square videos have an advantage in this case, as they are more visible and take up more screen space.
  3. Influence of network conditions. The speed and stability of the Internet connection affect the video quality. If the connection is unstable, the system automatically reduces the quality to maintain continuous playback.
  4. Bitrate limits. Bitrate limits have been set to optimize downloads.
  5. Optimal video settings. The following values are recommended for Telegram: resolution — up to 1920 x 1080 pixels, bitrate — 2000-4000 kbit/s, frame rate — 24-30 fps, format — MP4 (H.264).


Popular errors when sending text

400: Wrong video ratio

- Reason: Incorrect width`/`height (≠ actual resolution) is specified. 

- Solution: Delete the parameters or specify the exact values. 

413: Request Entity Too Large

- Solution: Compress video via ffmpeg: 

400: Can't parse caption entities

- Reason: An error in the HTML/Markdown markup of the signature. 

- Solution: Check tag escaping. 

403: Bot was blocked by the user

- Solution: Requires the user to unlock the bot.

Information

Technical information for the BOT-MARKET API

  1. The message type code (`MessageType') for sendVideo is "4".
  2. Max. Sending rate: 20 messages/second in channels


Tips for effective use :

1. Markup > Plain text: Use HTML for visual structuring. 

2. Content separation: For text > 4096 characters, use inline buttons with callback data. 

3. Escaping: Always handle special characters in user input to avoid parsing errors.