In a world where viral content reigns supreme, every video creator strives to maximize their video’s chances of success. But what if you could give an already shot video more chances of going viral without tedious manual editing of each version? This very idea sparked the journey of the UNIQ service, which transformed «vibecoding» into an efficient video processing conveyor.
From Idea to Product: The Beginning of UNIQ’s Journey
It all started with a simple question: how to give an already shot video more chances of going viral without manually editing each version? My friend, who actively publishes short videos, found a solution that evolved into the UNIQ service. The idea is simple: you send a video, choose the number of versions (one, five, or ten), and in return, you receive ready-to-publish files for Reels, Shorts, or TikTok. No editors, no struggling with each copy.
Initially, UNIQ was a working Telegram bot capable of processing videos using FFmpeg, changing frame parameters, tempo, color, sound, and adding effects. Telegram served as a convenient interface: send a video – get files. The product was there, the code was there, but the server question remained. The idea was called “giving a good video a second chance.”
First Obstacles: From Local Bot to Server Solutions
The prototype, created with the help of AI (my friend is not a programmer but managed to bring the idea to a working state), used Python, FFmpeg, and SQLite. For concept validation, it was convenient: launched on my Mac, sent a video, got a copy. But as soon as the first users appeared, problems began to surface:
- Lack of space: “Not enough free space on the server. Try again later.” My Mac quickly ran out of resources.
- Parallel processes: The second user who appeared in the test broke the “vibecoding.” Their actions should not have had to wait for other people’s orders to finish.
This required a rethinking of the architecture. It was obvious that serious server infrastructure was needed for scalability and stable operation. Today, UNIQ runs on six VPS, with its own control panel for processing, a database, monitoring, and updates. The bot can be found at: @uniqvideobot.
Solving Disk Space and Resource Problems
To process large files, we set up our own Local Bot API. Each order now included the source, temporary files, and ready copies. We added a disk budget and cleanup, ensuring that the file would fit, be processed successfully, and free up space. AI helped quickly write code, and we tested it in real-world scenarios.
How the Second User Changed Everything: From Vibecoding to Structure
The second user, who began actively interacting with the bot, identified a key problem: blocking. When FFmpeg processed one user’s video, another could not start their order. This led to the need to:
- Figure out who was blocking whom.
- Determine where process states were stored.
- Find out what could be executed in parallel.
Instead of a complete rewrite in Go, which would not have solved the general blocking problem, we separated network waiting, database queries, and encoding. This is how the task queue emerged.
Databases and Fault Tolerance: From SQLite to PostgreSQL
Initially, SQLite was used, which was convenient for a prototype. However, for working with queues, concurrent transactions, and distributing tasks between different VPS, it proved insufficient. We switched to PostgreSQL, which offered:
- A shared database.
- Concurrent transactions.
- Row-level locking.
This ensured that two handlers would not pick up the same order, and a repeated click would not lead to double reservation of funds. SQLite remained for its own inventory in the control panel.
Order Lifecycle Management: Lease, Tokens, and Checkpoints
To ensure reliable order processing, especially in case of failures, a «lease» system was introduced:
“As long as A is alive, it extends the lease. If the term expires, B can take the order.”
This allows another handler (B) to pick up the task if the first one (A) hangs. To prevent conflicts, the following are used:
- Owner tokens: Each state record checks the token so that a woken-up A cannot change an order that B is already processing.
- Checkpoints: Saved continuation points, allowing handler B to start work not from scratch, but from where A left off.
- Receipts: Protection against re-modifying an order in case of API response loss.
Even canceling an order became a complex process, requiring stopping encoding, waiting for child processes and background file operations, before closing the job and deleting the folder.

Financial Logic: Coins, Batches, and Transactions
Monetization
Initially, processing was free, but monetization required:
- Starter coins.
- A referral system.
- Manual accruals and purchases.
Each accrual is stored as a separate batch with its own expiration date. If a user cancels a paid order, the coins are returned to their original batch with the initial expiration date, rather than «rejuvenating» the wallet. This prevents abuse and ensures financial stability.
Example: A user has 50 coins, a copy costs 4. They order 5 copies (20 coins are reserved). They cancel 3 copies. 8 coins are debited for the completed copies, 12 are released from reserve. Result: 42 available coins, the expiration date of the returned coins remains the same.
Telegram Stars, ЮKassa, and GetPlatinum are integrated for payment processing, with encryption of details and separate currency accounting.
Performance Optimization: S3, PgBouncer, and Long Polling
As the load grew, new bottlenecks became apparent:
- Video dependence on local folder: For scaling, videos were moved to S3, and only keys, sizes, and SHA-256 were stored in PostgreSQL.
- Database connections: To avoid multiple connections to PostgreSQL for each client, PgBouncer was implemented to pool connections.
- Constant queue polling: To reduce database load when checking the queue, long polling was introduced. An HTTP request waits for work without holding an SQL connection.
Separating Encoding and Delivery
Initially, the bot prepared all copies and then sent them all at once. This led to delays, as the first completed copy waited for the others. We separated encoding and delivery: the worker publishes the copy and a checkpoint, and the gateway sends it immediately. This significantly reduced user waiting time. For example, when processing five copies, the first copy was sent 131 seconds earlier than the entire order was ready.
Frequently Asked Questions
What is UNIQ?
UNIQ is a Telegram bot-based service that allows you to automatically create multiple versions of videos for publication on Reels, Shorts, or TikTok from a single source file, without manual editing.
What technologies are used in UNIQ?
UNIQ is based on Python, FFmpeg for video processing, PostgreSQL for the database, S3 for file storage, and PgBouncer for optimizing database operations.
How does UNIQ ensure fault tolerance?
Fault tolerance is achieved through a «lease» system for tasks, owner tokens, checkpoints for resuming work after failures, and receipts to protect against repeated operations.
Can I order 20 clips from a stream via UNIQ?
Currently, the service offers a choice of 1, 5, or 10 video versions. The ability to mass-cut 100+ clips or 20 from a stream may be implemented in the future, based on user needs.
How long does video cutting take?
The cutting time depends on the length and complexity of the source video, as well as the number of requested copies. By separating encoding and delivery, the first copies are delivered to the user significantly faster than the entire order is completed.
Conclusion: continuous development and optimization
UNIQ’s journey from vibecoding to a stable service is a story of continuous problem-solving and optimization. Every new user and every error became a catalyst for architectural improvement. We learned not just to «add a server,» but to precisely understand where and why to add it. Now the system is ready for scaling, and we continue to work on improving the user experience. Optimize your processes and achieve maximum productivity!
