AutoReel Contact
← The AutoReel blog
Technology29 Oct 20267 min read

How one video is built: engines, encoding and the GPU

A 9:16 video is not made in one step. This walks the six stages of the pipeline, the two places parallel jobs collide, and the stages a graphics card cannot rescue.

Tiếng Việt

A 9:16 video crosses six stages, and any one of them can sink it

You press render, go make coffee, and come back to an mp4. In between there are six stages: fetch the source, cut it, voice it, burn subtitles, brand it, check it.

Each stage takes a file and returns a file. When a video comes out wrong, the first question is not "why does it look bad" but "which stage failed" — because each stage fails in its own way, and each is fixed differently.

A left-to-right diagram of the render pipeline: a source is fetched, cut into 45-second 9:16 windows, voiced by one of two on-machine engines, has subtitles burned into the picture, gets a frame and logo applied, then passes a QC gate to become a file ready for posting. Below left is the clip-cache branch with a hidden temp file and a rename; below right is the GPU branch with hardware and software encoding paths; the bottom strip lists the QC conditions.
Every arrow is a closed file. A failure stops at its own stage, which makes finding it cheaper than guessing at the whole pipeline.
  1. Fetch. A link is preflighted before download: missing cookies are reported then, not twenty minutes later. A file already on disk is reused, but only if it probes to a positive duration.
  2. Cut. The source is transcribed, scored, then cut into 45-second windows and cropped to 9:16. This is the stage that fixes the final shape.
  3. Voice. The lines are spoken by an on-machine engine, or by a dubbed translation. This stage writes the audio file and decides the final length.
  4. Burn subtitles. Captions are drawn into the picture during the final encode, not laid over it afterwards.
  5. Brand. The frame, logo and two lines of text are drawn into the source picture itself, so the result stays 9:16.
  6. Check. The last gate reads the file and answers pass or fail with a reason. No model takes part in that answer.

A finished download is not a usable file

A download killed halfway still sits on disk at a believable size. It has no index, so the reader reports zero seconds.

The system does not trust the size. It opens the file and asks for the duration; only a positive number lets it be reused. A 41 MB remnant of a failed download was reused repeatedly because the old check only looked at size. Now that file is deleted and fetched again.

Cut before dubbing, because dubbing keeps the length

A Facebook Reel runs 90 seconds at most. Dubbing, logo removal and branding all keep the source length. Hand in a seven-minute landscape drama and all three work on those seven minutes, then QC refuses the result at the end.

So for a Facebook target, a source longer than 90 seconds is cut to a 45-second 9:16 window first. A source already inside the limit is left alone — trimming a 40-second vertical clip just to trim it loses footage for nothing.

The cut is not random. The source is transcribed, scored on picture and sound signals, then windows are chosen. The default is 45 seconds: long enough for a story to open and close, and far enough below the 90-second ceiling that the voice cannot push the video over it.

A voice is chosen by prefix, not by menu

The voice list on screen merges two on-machine engines into one picker. So the engine has to travel with the name, written as a prefix: "vieneu:Hải Đăng", or the older engine’s own prefix.

Only those two prefixes are recognised. A bare name — maichi — falls back to the older engine and keeps the whole string as the voice name. This is the easiest place to get wrong when editing configuration by hand: no error, no warning, just a different voice from the one you meant.

  • The first engine has 8 fixed voices. A ninth needs new voice data, and that data is not something a user can produce.
  • The second has 25, named as proper nouns and never translated. "Adam bựa" is not "Adam"; matching is exact, never by prefix.
  • Both run on the CPU. The first decodes one frame at a time, one thread per call; the only way to use the whole machine is several segments in flight, capped at 8 at once.

Subtitles burn in the same encode, and the cost is the animation

There are two ways to burn captions. The old one composited every frame in Python: decode a frame, draw text, encode it back. On a 36-minute 1080x1920 video that ran at 0.19x realtime — slower than every other stage added together.

The current path hands the subtitle file to the encoder itself. Same video, same file: 1.50x realtime, roughly eight times faster. The burn alone costs almost nothing: 0.388 against 0.412 with no subtitles at all.

What it gives up is animation. The old path had cues that sprang into place, centring measured from the ink, and a rounded background. The new one keeps the font, size, colour, outline and position, but holds still. If that motion is part of a channel’s identity, you choose between it and eight times the speed — there is no free option.

Branding is another full encode, so an empty template has to be free

Every branding template reads the whole video and writes a new copy. Twenty videos in a batch means twenty extra encodes — which is why an empty template must return the original path without running a single command.

An empty text box must also travel as an empty string, not as "not set". The two differ: empty means "no words here", while "not set" means "use the template’s own words". One video shipped with a title nobody wrote because the blank box arrived as "not set".

The branded frame follows the source’s own shape, so a 9:16 video stays 9:16. Phone video records its coded size as landscape in most formats; the system reads the display matrix to find the real frame, otherwise the bars land on the wrong two sides.

Shared stills: one temp file, one rename

When several videos draw on one set of stills, each video turns every still into a short clip. Writing straight to the final name failed two ways at once, and it really did fail: on 5 October 2026, five tasks sharing three stills all wrote to the same three names, and four of the five died after minutes of rendering because they opened a file still being written.

An mp4 keeps its index at the end. A file still being written has no index, so the reader says "moov atom not found" — which reads like a corrupt file and is really an unfinished one.

The fix has three parts. Each clip is written to a hidden temp file beside its target, with a random name. One lock per target means only one process renders it. Then a single rename, on the same filesystem, so a reader sees either the old complete file or the new complete file and never half of one.

Before rendering, the system opens the target and checks its duration. If the length is right, it reuses it. Five identical renders become one.

The GPU only helps when the container is handed the right things

A hardware encoder does not come for free. The default container asks for no card, because a machine without the NVIDIA driver dies at container-create time instead of warning and carrying on. Getting the card means enabling a second configuration file, and that file adds three things at once: permission to use the device, an encoder build with hardware support compiled in, and the variable that points the engine at it.

Missing either of the last two is worse than not enabling it: a device nobody uses, or every task failing at the first check.

The permission has to be the right one. "gpu" alone mounts the compute libraries; encoding also needs "video", which carries the encode library. Without it the error looks like a bad parameter — "cannot open encoder" — and you will spend an afternoon adjusting bitrate while the cause is a library that was never mounted.

Even when everything is granted, the encoder can still fail at runtime. The system falls back to the software encoder and rests the hardware one for five minutes before trying again. The measured session ceiling on one card is 12: twelve simultaneous 1080x1920 encodes succeeded, the thirteenth was refused. Hence two ceilings: 8 workers per task, and 12 sessions for the whole machine, shared through a lock folder both processes can see.

The trade is quality. At the same bitrate a hardware encoder usually looks rougher than the software one at a slow preset; it trades picture for speed and low CPU. For a sales video posted daily that is often worth it; for a brand film it is not.

The final gate reads the file, not the mood

Before anything is posted, a gate opens the file. It does not score the content. It answers questions that are only true or false.

  1. Is the ratio 9:16? Tolerance is 0.02, wide enough for pixel rounding and narrow enough to catch 16:9.
  2. Is there an audio stream, and how long is the file? Under 2 seconds is refused; over 90 is refused for Facebook, over 180 for YouTube and TikTok.
  3. Is more than half the picture black? A window shorter than its voice once produced 15.3 seconds of black in a 30-second video, and the gate caught it.
  4. Is this file byte-identical to an earlier video? It compares hashes; a match is refused.

A missing subtitle file is only a warning, because some platforms generate captions and some accept burned-in ones. A missing audio stream is an error, because no platform can rescue a silent video.

Three limits to know before trusting a speed number

  • Voice is the CPU stage. It does not use the card, and one long segment cannot be split across cores. Eight segments in parallel speed up a batch; they do not shorten one long segment.
  • Hardware encoding is faster but not free. At the same bitrate the picture is usually weaker; keeping quality means raising the bitrate, and the file grows.
  • The clip cache only helps when videos share stills and the same clip length. Change the length and the target changes, and everything renders again.
Do not measure the pipeline on a 15-second video. On a short clip, fixed costs — loading the model, starting the engine, opening files — dominate. On a five-minute video, voice and cutting dominate. The two measurements point in opposite directions on the same machine, and both are right.

Frequently asked questions

Does a 9:16 video have to be exactly 1080x1920?

No. The gate checks the ratio, not the pixel count: 720x1280 passes. What it blocks is a 16:9 frame dressed as vertical, because the platform will crop the sides and take the subject with them.

Why does a 40-second video still take minutes?

Length does not set the time. Three fixed costs — loading the voice model, reading the source to pick scenes, opening and encoding the file — dominate on a short clip. Only as the video gets longer does the length-dependent work take over.

Which stage does the graphics card help?

Encoding only. Voice runs on the CPU with no GPU path, and so do the transcript and the cut. A machine with a card waits just as long for the voice as one without.

Can I keep the old animated subtitles?

Yes, by switching the subtitle renderer in configuration. The price is speed: the old path is roughly eight times slower on a long video, so it suits short clips or brand videos that need the motion.

Automate the repetitive part

AutoReel does most of what these articles describe: reads the product, writes the script, builds the video, then publishes it to Shopee Video and Facebook/Reels. Rent it from $6.99 a month, or buy it once and keep it.

See pricing Talk to us

More articles

Technology29 Oct 2026

One machine, no cloud: what runs where

Interface, orchestrator, engines, one data file, a licence guard and Chrome — all on one machine. The map of the five roads out, and why each exists.

Technology29 Oct 2026

Why a job survives the app being restarted

A job lives on disk, not in memory: where the row is written before the work starts, what comes back after a restart, and why three queues differ.

Technology29 Oct 2026

Six video sources, three ways to fetch

Four platforms answer a keyword, two take only a link. When yt-dlp is enough, when Chrome is needed, when a page read will do — the decision tree for six sources.