YouTube: Upload & Processing Deep Dives
How does a 10 GB upload survive a broken connection?
One Request Cannot Resume
The simplest upload is one PUT of the whole file. If the connection breaks, nothing is kept: in our test against MinIO (an S3-compatible store), 4 MiB of an 8 MiB PUT arrived before the connection dropped, and afterwards no object existed. The next attempt starts again from byte 0 — for a 10 GB file broken at 80%, eight gigabytes again.
Two Ways to Resume
Object stores solve this in two ways, and both work with uploads that go straight from the client to storage:
| Google Cloud Storage (and YouTube's Data API) | Amazon S3 | |
|---|---|---|
| Shape | one session; the file is sent in chunks, in order | a multipart upload; each part is its own PUT |
| Sizes | chunks in multiples of 256 KiB | parts of at least 5 MiB (except the last), at most 10,000 |
| After a break | an empty PUT with Content-Range: bytes */SIZE; the answer, 308, says which bytes arrived | list the parts already stored; send the rest |
| Finishing | the last chunk completes the object | a request listing every part completes it |
| Lifetime | a session "remains active for up to a week" | until completed or aborted; Amazon recommends a lifecycle rule with AbortIncompleteMultipartUpload to delete the abandoned ones |

We ran the multipart version: a 26 MiB file in six parts, five of 5 MiB and a last one of 1 MiB. The client sent three, then "crashed". The resumed client asked the store, which listed parts 1, 2 and 3 — 15 MiB that did not have to travel again — and sent the other three. The completed object's SHA-256 equalled the file's. Two details matter for a real system:
- The ETag is not a checksum of the file. The finished object's ETag ended in
-6, the number of parts: a multipart ETag is built from the parts. So the client declares the file's SHA-256 when it starts, and the server checks it before anything is processed. - Too-small parts fail late. A 1 MiB first part was accepted when sent and refused only at completion, with
EntityTooSmall. The client must size its parts from the start.
Where a session starts matters too: "Resumable uploads are pinned in the region where you initiate them" — a session opened in the US for a client in Asia carries every byte across the Pacific. The upload service therefore opens each session in the region nearest the uploader.
What a Signed URL Grants
Uploads bypass the API servers: the API hands the client a URL that object storage accepts without the user's credentials. We tested what such a URL allows, with S3 signature version 4 (AWS4-HMAC-SHA256) against MinIO:
| Attempt | Result |
|---|---|
PUT with the URL | 200, stored |
GET with the same URL | 403, SignatureDoesNotMatch — the method is part of the signature |
PUT by a second client with no credentials, holding only the URL | 200 — the object now held that client's bytes |
PUT with the object key changed in the URL | 403, SignatureDoesNotMatch |
PUT one second after the URL expired | 403, AccessDenied |
PUT of 8 MiB, nothing about size in the signature | 200 |
The same with the length signed (content-length;host), sending 2 MiB | 403 |
| A form upload (POST policy) limited to 1 MiB, sending 2 MiB | 400, EntityTooLarge |

The third row is the one to remember. A signed URL is a bearer credential: Google's documentation says "anyone who possesses it can use the signed URL to perform specified actions, such as reading an object, within a specified period of time." Both stores cap a version-4 URL at 7 days. So the design limits what a leaked URL can do:
- One fresh object key per session. A leaked URL can overwrite only its own unfinished upload, never a published video or someone else's.
- Short lifetimes, a bounded size. Sign the exact length, or use a form upload with
content-length-range; a plain signedPUTtakes any size. - Check before use. Processing starts only after the stored object's SHA-256 matches the one the creator's authenticated client declared.
How the URL is signed depends on the store. S3's version 4 derives an HMAC key from the secret access key. Google Cloud Storage signs with RSA-SHA256 using a service account's private key, or with an HMAC key. Either way the store recomputes the signature over the method, the path, the expiry and the signed headers, which is why changing any of them fails.
Faster Uploads
Uploading in parallel helps only while one connection cannot fill the link — high latency, losses, a per-connection cap. When the link itself is full, splitting the file changes nothing: 10 GB over 50 Mb/s takes 1,600 seconds, about 27 minutes, however it is cut. What does help is starting the session near the uploader, keeping chunks large enough that per-request overhead stays small, and resuming instead of restarting.
Re-encoding on the phone to shrink the upload does not help either. A fast preset needs more bits for the same quality: on our busy scene x264's veryfast preset reached VMAF 94.8 at 6.1 Mb/s, where its default preset reaches the same VMAF at about 4.5 Mb/s — 37% more. A smaller file means lower quality instead, and processing re-encodes the upload anyway; YouTube recommends uploading at bit rates such as 8 Mb/s for 1080p and 35–45 Mb/s for 2160p.
Which codecs, and what do they cost?
Three Codecs, Measured
A codec trades bits against computing: the newer ones need fewer bits for the same picture and more work to find them. We measured the trade on two 10-second scenes of Tears of Steel (1920×800, 24 frames a second) — the calmest and the busiest 10 seconds of the film by bit rate at a fixed quality — scoring every encode with VMAF, the perceptual quality metric Netflix built and open-sourced. Each codec ran as its makers recommend for on-demand video: H.264 with x264's default preset, VP9 in two passes with Google's VOD settings, AV1 with SVT-AV1 preset 6.

| Bit rate for VMAF 93 | Calm scene | Busy scene |
|---|---|---|
| H.264 | 0.52 Mb/s | 3.48 Mb/s |
| VP9 | 0.25 Mb/s | 3.27 Mb/s |
| AV1 | 0.18 Mb/s | 2.44 Mb/s |
Averaged over the streaming range (VMAF 80–96):
- VP9 against H.264 saved 49% on the calm scene and only 10% on the busy one.
- AV1 against VP9 saved 30% and 31% — the one saving that held on both.
- AV1 against H.264 saved 65% and 37%.
There is no single "VP9 is 30% better" number: the saving depends on the content. The busy scene also needed 7 to 14 times the bits of the calm one for the same quality — the reason a fixed ladder wastes bits on simple videos (next section).
What the Saving Costs
We timed each encoder on the busy scene, reading it as raw frames so that decoding the source costs nothing — decoding our lossless copy of the scene alone took 0.53 CPU-seconds per second of video, enough to distort a comparison:
| Encoder (busy scene) | CPU-seconds per second of video | Bit rate | VMAF |
|---|---|---|---|
| x264, default preset (CRF 23) | 1.31 | 6.5 Mb/s | 97.1 |
| x264, veryfast (CRF 23) | 0.47 | 6.1 Mb/s | 94.8 |
| VP9, two passes, Google's VOD settings (CRF 36) | 9.33 | 5.7 Mb/s | 96.2 |
| SVT-AV1, preset 6 (CRF 36) | 2.38 | 5.2 Mb/s | 95.8 |
| SVT-AV1, preset 10 (CRF 36) | 0.61 | 6.2 Mb/s | 93.3 |
VP9 took 7.1 times the computing of H.264 — YouTube's own account says "data-efficient video codecs like VP9 use more computer resources to encode than H.264." AV1 is not uniformly slower: SVT-AV1, an encoder built for this scale, took 1.8 times H.264 at preset 6, and at preset 10 less than half — for a lower VMAF.

YouTube's Answer: Its Own Chip
YouTube began designing a transcoding chip in 2015 and described it in 2021: the Video Coding Unit. "We've seen up to 20-33x improvements in compute efficiency compared to our previous optimized system, which was running software on traditional servers." Hardware gives up a little quality — "VCU H.264 encodings are on average 11.5% higher BD-rate than libx264, and VCU VP9 is 18% greater BD-rate than libvpx" — and still wins overall: "VCU leverages the improved coding efficiency of VP9 relative to H.264 to achieve 30% BD-rate improvement relative to libx264. The high compute cost of VP9 makes it computationally infeasible at scale in software."
A general-purpose hardware encoder is not a substitute. Apple's VideoToolbox, the real-time H.264 encoder in Macs and iPhones, ran the busy scene in 0.8 seconds against x264's 1.5 — and at x264's bit rates scored VMAF 89.7 against 96.4 at 5.7 Mb/s, and 73.1 against 86.8 at 1.8 Mb/s. Real-time encoders are built for speed; a chip for an archive is built for quality per bit.
Which Codecs to Keep
| Codec | Plays on | Role |
|---|---|---|
| H.264 | everything | the fallback; Apple's streaming guide says "For backward compatibility, some video content SHOULD be encoded with H.264" |
| VP9 | Chrome, Firefox, Edge, Android; Safari | the main format where it decodes in hardware |
| AV1 | Chrome, Firefox, Edge; Safari "only on devices with hardware decoder, e.g. iPhone 15 Pro, M3 MacBook Pro" | the most efficient, where the device can play it |
The newest codec is worth its encoding cost where the bits it saves are delivered many times: a video watched a million times pays for its AV1 encode in bandwidth; one watched 35 times — the median — may not. So the scheduler can encode the compatible codecs first for every video and the most efficient codec for videos whose views justify it.
What does a ladder weigh, and who chooses it?
What a Ladder Weighs
A ladder is the set of renditions a video is offered in: resolutions, each with a bit rate, for each codec. We encoded the 20 seconds of Big Buck Bunny (4K, 30 frames a second) whose source bit rate is the film's median, three ways: VP9 exactly as Google's VOD table prescribes for each frame size, H.264 at the bit rates of Apple's HLS table, and AV1 with SVT-AV1 at one quality setting.

| Rung | VP9 (Google's table) | H.264 (Apple's table) | AV1 (SVT-AV1) |
|---|---|---|---|
| 2160p | 11.06 Mb/s | — | 4.65 Mb/s |
| 1440p | 4.84 | — | 2.60 |
| 1080p | 1.70, VMAF 95.3 | 5.90, VMAF 97.4 | 1.71, VMAF 95.7 |
| 720p | 0.90, VMAF 90.2 | 2.94, VMAF 93.4 | 0.93, VMAF 90.9 |
| 480p (H.264: 432p) | 0.65, VMAF 83.9 | 0.73, VMAF 81.2 | 0.51, VMAF 83.0 |
| 360p | 0.26, VMAF 69.5 | 0.37, VMAF 70.8 | 0.34, VMAF 73.8 |
| 240p (H.264: 234p) | 0.15, VMAF 49.1 | 0.15, VMAF 44.6 | 0.20, VMAF 54.6 |
| Whole ladder | 19.5 Mb/s | 12.1 Mb/s (plus a 540p rung) | 10.9 Mb/s |
VMAF here is measured on a 1080p screen, so the small rungs score low; on a phone they look far better. Two conclusions follow:
- The renditions are not a multiple of the upload. All three ladders together come to 42.5 Mb/s, about what YouTube advises a 4K upload to be (35–45 Mb/s). For a 1080p upload at the advised 8 Mb/s, the VP9 and H.264 ladders up to 1080p come to 15.7 Mb/s, about twice the upload. Storage grows by one to a few times the uploads, not by an order of magnitude.
- A fixed table wastes bits on easy content. VP9's settings cap the bit rate but let the encoder spend less when the picture is simple; at 1080p it used 1.7 Mb/s of its 1.8 Mb/s target. The H.264 table fixes the rate, so the same rung spent 5.9 Mb/s on the same simple film.
Per-Title Encoding
The codec measurements showed the busy scene needing 7 to 14 times the bits of the calm one for the same VMAF. A ladder chosen per video spends bits where the picture needs them. Netflix introduced it in 2015: "We've spent years developing an approach, called per-title encoding, where we run analysis on an individual title to determine the optimal encoding recipe based on its complexity." For one title they report: "At the high end, the new per-title encoding assigns 4640 kbps for the highest quality 1080p encode. This is 20% in bitrate savings compared to 5800 kbps for the fixed ladder scheme."
Per-title encoding costs extra encodes to find the ladder, so it pays where views are many: a popular video's ladder is worth refining; one watched 35 times is not.
How does the processing graph run, and in what order?
The Graph in a Table
Each upload's processing is a set of tasks with dependencies — probe the file; check it; for every rung an encode and then a package step; publish when the low path and the check are done. The graph lives in the tasks table of the data model, one row per task, with the tasks it needs and a priority. Workers take tasks with one statement:
-- take one task whose needs are all done, and lease it for five minutes
UPDATE tasks t
SET state = 'running', attempts = attempts + 1, lease_until = now() + interval '5 minutes'
WHERE (t.video_id, t.task) = (
SELECT c.video_id, c.task
FROM tasks c
WHERE (c.state = 'waiting' OR (c.state = 'running' AND c.lease_until < now()))
AND NOT EXISTS (SELECT 1 FROM tasks d
WHERE d.video_id = c.video_id AND d.task = ANY (c.needs) AND d.state <> 'done')
ORDER BY c.priority, c.video_id, c.task
LIMIT 1
FOR UPDATE SKIP LOCKED)
RETURNING t.video_id, t.task, t.attempts;- Ready only. A task is taken only if every task it needs is
done. - No double work.
FOR UPDATE SKIP LOCKEDmakes concurrent workers pass over a row another worker is taking, instead of waiting for it or taking it too. - A lease, not a lock. The worker gets five minutes; a task whose lease ran out is taken again, so a crashed worker delays its task by the lease, nothing more.
- Fencing. The worker reports success with
UPDATE … WHERE state = 'running' AND attempts = <its attempt>. A worker that was presumed dead and finishes late names an old attempt and changes nothing.
We tested these on PostgreSQL 17. The schema refuses a state it does not know (published fails the CHECK). A task claimed by one worker could not be claimed by another while its lease ran; once the lease ran out it was taken again as attempt 2, and the first worker's late report changed 0 rows. Four workers ran the 29 tasks of one upload's graph with no task starting before its needs ended and none taken twice.
The Order Decides When It Plays
The same graph of one 20-second 4K upload, the same four workers, three orders — each task taking its measured time (the encodes as timed reading the H.264 upload, over a worker's four cores):

| Order | Playable | All renditions done |
|---|---|---|
| First created, first taken | 53 s | 172 s |
| Low path first, then by height | 7 s | 187 s |
| Low path first, then the longest encode first | 7 s | 162 s |
The low path first makes the video watchable at once. What follows decides when the last rendition is ready: the 2160p VP9 encode alone took 161 seconds, so the graph cannot finish sooner, and starting it early reaches that bound. Started last, it pushes everything out by 25 seconds. The scheduler therefore orders by two rules: the path to the first playable version, then the longest work.
Checks Before Publishing
The check runs beside the low path and gates publish. It covers the platform's rules and copyright: "Using a database of audio and visual files submitted by copyright owners, Content ID identifies matches of copyright-protected content. When a video is uploaded to YouTube, it's automatically scanned by Content ID." Matching compares the video's sound and pictures with the reference files, so it must read every frame; we time it as one full decode of the upload. A match can block the video, which is why blocked is a state of its own.
How is one video encoded on many machines?
One Video, Many Workers
A worker encodes one rendition, but one rendition of a long 4K video is hours of computing. Cutting the video into chunks lets many workers encode one rendition at once. We cut 120 seconds of Tears of Steel into chunks at keyframes and encoded them in parallel with the same settings:

| Run | Wall clock | CPU-seconds | Size | VMAF |
|---|---|---|---|---|
| One worker, whole video | 48.4 s | 113 | — | 95.33 |
| 5 chunks of 24 s, 5 workers | 18.5 s (2.6×) | 175 | +0.4% | 95.32 |
| 10 chunks of 12 s, 10 workers | 19.0 s (2.5×) | 170 | +0.7% | 95.30 |
The joined files had all 2,880 frames and decoded without an error; they were 0.4–0.7% bigger, the small price of starting each chunk afresh. The speed-up stopped at 2.6× because all workers shared one laptop of ten cores, six of them slower efficiency cores, and the same work took half as many CPU-seconds again. Across machines, the wall clock approaches the time of the slowest chunk.
Chunking needs cuts at keyframes the encoder will keep, so each chunk decodes on its own and the joined file is seamless. The same requirement appears again for the player, below.
How do segments let the player switch quality?
Segments a Player Can Switch Between
The player changes quality between segments. That works only if every rendition's segments start at the same instants, each with a keyframe (an IDR frame) that decodes without earlier frames. Apple's HLS rules say it outright: "Video segments MUST start with an IDR frame", "Key frames (IDRs) SHOULD be present every two seconds", "Target durations SHOULD be 6 seconds", and "Media Segments MUST NOT exceed the target duration by more than 0.5 seconds."
Encoders do not do this on their own. We measured where they put keyframes:

- x264 with its defaults put keyframes at scene cuts — at 10.4, 14.9, 19.9 s and so on. Asked for 4-second segments, ffmpeg's DASH packager could cut only 8 segments, of 4.5 to 11.0 seconds. Here the two renditions happened to get the same keyframes; nothing guarantees it.
- VP9 with Google's VOD settings — keyframes "up to 240 frames" apart, which "allows the encoder to choose the best placement of keyframes" — gave six rungs keyframes at the same seven instants, but the 240p rung lacked the one at 10.70 s. A player could not switch to or from 240p there.
- A keyframe forced every 2 seconds in every rendition gave 15 segments of exactly 4 seconds in both renditions.
So the encode tasks of a ladder all force keyframes at the same fixed interval, and scene-cut keyframes are switched off or kept only in addition. The cost is a few extra keyframes; the gain is that every segment boundary is a switch point in every rung.
Packaging
Packaging cuts the encoded file into segments and writes the manifests, without encoding again. The same aligned encode can serve both formats: DASH (an MPD listing each representation's segments) and HLS (a playlist per rendition — published as RFC 8216, an Informational RFC). Packed as HLS with fMP4 segments of 6 seconds, our aligned 1280×534 rendition became 10 segments, a target duration of 6 and one initialization segment (EXT-X-MAP). Both formats can carry the same fragmented-MP4 segments, so one copy of the bytes can serve every player.
Starting Before the Upload Ends
Processing could start before the last byte arrives, if the partial file can be read. An MP4 has an index, the moov box, that says where every frame is; ffmpeg writes it at the end by default. We cut three 30-second files at their halfway byte:

| Layout | First half |
|---|---|
| Index at the end (ffmpeg's default) | does not open: "moov atom not found" |
Index first (+faststart) | opens; 389 of 720 frames decode |
| Fragmented (an index per fragment) | opens; 389 of 720 frames decode |
Uploads come in whatever layout the camera or editing software wrote, and ffmpeg's own default puts the index last. So the design waits for the complete, hash-checked upload before processing; early processing is an optimisation only for files that put the index first.