🎬

Telegram media bot: video and audio from a link, right in the chat

our own bot: quality choice up to 4K, MP3 with cover art, files up to 2 GB

A Telegram bot that takes a link to a clip and sends the file back to the same chat: quality choice with the file size shown in advance, MP3 with cover art, FFmpeg compression and splitting, files up to 2 GB through a local Bot API, instant repeats from the file_id cache and a button-based admin panel.

In production Β· in-house product
up to 4K
quality choice from 240p, the file size is shown on the button in advance
2 GB
file ceiling with a local Bot API instead of the cloud API's 50 MB
30 days
a repeated link is answered instantly from the file_id cache

The task

To get a clip or its audio track in a convenient form, you usually have to go to a third-party site: put up with ads, get caught in redirects, then hunt for the file on your phone to forward it to a friend. Such services break regularly or ask for payment.

We needed a bot that lives where the conversation already is: you drop a link into the chat and get the file in the same chat. It can be forwarded to anyone right away, because it is already in Telegram.

The solution

Our own Telegram bot, version 2.6.3. What was done:

  • Quality choice. From 240p to 4K, with the file size shown on the button in advance.
  • Audio separately. MP3 with cover art and metadata; the bitrate follows the clip's best track, from 192 to 320 kbps.
  • Instant repeats. Anything already processed is sent by file_id with no repeated work.
  • Live progress. A progress bar, speed and time remaining.
  • Large files. Automatic FFmpeg compression or splitting into parts; up to 2000 MB with a local Bot API.
  • Default format. The /format command: the preferred quality straight away, with no questions.
  • Admin panel. A summary, daily analytics, users, moderation, broadcasts with a delivery report, settings on the fly, logs, maintenance.

The link does not have to come as a separate message: the bot finds it inside any text.

How it works

A queue and separate processes

The bot reads a link once, gets the list of variants with their sizes and reuses that result, saving a network request. Heavy work runs in separate threads and processes, so while someone else's file is being processed, the bot keeps answering everyone else; a semaphore limits the number of simultaneous tasks, and a stuck link is cut off by a timeout with a clear error.

Files over 50 MB: a local Bot API

Telegram's cloud Bot API does not let a bot send a file larger than 50 MB. The bot shows the size of each variant in advance, marks those that exceed the limit but can be compressed, and recompresses the file with FFmpeg, lowering the resolution if needed. If the quality would become unacceptable, the bot offers to split the file into parts. For files up to 2000 MB, docker-compose describes a local Bot API server: in local mode it returns a path on disk instead of a link, and the bot works with the same files.

The file_id cache

Every file uploaded to Telegram once gets a file_id identifier. The bot keeps it in SQLite and, on a repeated link, forwards the file instantly with no traffic. The cache lifetime is configurable, 30 days by default.

The admin panel

It runs on inline buttons under the message: a summary, daily analytics, top errors, users with search, bans with a reason, broadcasts with a preview and a report, limits and maintenance mode, logs, server status, cache cleanup, database export. Users who have blocked the bot are removed from the database automatically after a broadcast.

Results

  • A link into the chat, a file in reply: no third-party sites and no ads.
  • Quality from 240p to 4K, MP3 with cover art, the file size known in advance.
  • Files over 50 MB are compressed, split or sent whole through a local Bot API up to 2000 MB.
  • Repeated links are answered from the cache with no repeated processing.
  • Fast test suites (unit tests and routing with a fake Telegram) need no network.

Technologies and why

  • Python and aiogram 3: an asynchronous bot, inline keyboards, anti-flood and maintenance mode in middleware.
  • FFmpeg: MP3, compression, splitting, previews, joining.
  • SQLite (aiosqlite): users, the log, the file_id cache, settings.
  • Local Bot API (telegram-bot-api): an optional profile for files up to 2000 MB.
  • Docker Compose: the bot and auxiliary services, profiles enabled with a flag.

Status

Our own product, in production. The current version is 2.6.3 of 27 September 2026. Tests are run manually, there is no CI.

Questions about this project

How do you send a file larger than 50 MB in Telegram?
The cloud Bot API does not let a bot send a file larger than 50 MB. The bot marks heavy variants in advance, recompresses the file with FFmpeg or splits it into parts. With a local Bot API server the ceiling rises to 2000 MB.
Why is a repeated link answered instantly?
A file already uploaded to Telegram is cached by its file_id and forwarded with no repeated processing and no traffic. The cache lifetime is configurable, 30 days by default.
What does the administrator see?
A button-based admin panel under the message: a summary, daily analytics, top errors, users with search, moderation, broadcasts with a delivery report, settings on the fly, logs and maintenance mode.
Can such a bot be built for our own task?
Yes. The task queue, quality choice, FFmpeg compression and splitting, the cache and the admin panel carry over to another media flow: for example, processing your company's own clips or delivering webinar recordings.

Need something similar?

Tell us about the task β€” we'll show how we solved it and estimate the scope.