What is compression?
The short version: writing the same video down in less space.
A video is thousands of pictures shown quickly. Stored in full, that is enormous. Compression notices that most of each picture is the same as the one before it, so it only stores what changed. It also drops fine detail your eyes can't pick out, the way a photo can be saved as a smaller JPEG without looking different.
Done well, you won't see a difference. The file is often a third to a half of the size, sometimes much less. That is good for everyone:
- Faster uploads for you.
- Quicker starts and less buffering for anyone watching, especially on slow connections or mobile data.
- Less load on DarkDeck, which keeps it cheap to run and fast.
More detail
How it works
Modern video codecs such as H.264 (also called AVC) split each frame into blocks. Most frames are stored as differences from nearby frames: a block that merely moved is described by a movement, not stored again. What remains is passed through a transform that separates coarse shapes from fine detail, and the finest detail, the part human eyes notice least, is stored less precisely. The result is then packed with entropy coding, like zipping the leftovers.
Bitrate decides size
File size is roughly bitrate × duration. A 30-minute video at 8 Mbit/s is about 1.8 GB. At 4 Mbit/s it is about 0.9 GB. Screen recordings and phone videos are often recorded at generous bitrates, so there is a lot of room to shrink them with very little visible change.
Resolution
Fewer pixels means fewer bits. Typical sensible bitrates for H.264:
| Quality | Good for | Typical bitrate | Size per 30 min |
|---|---|---|---|
| 360p | very slow connections | 0.6 Mbit/s | ~135 MB |
| 480p | mobile data | 1.1 Mbit/s | ~250 MB |
| 720p | most phones and laptops | 2.4 Mbit/s | ~540 MB |
| 1080p HD | big screens | 4.5 Mbit/s | ~1.0 GB |
| 4K | TVs and large monitors | 14 Mbit/s | ~3.1 GB |
Lossy, but gentle
This kind of compression is lossy: some information is discarded for good. The aim here is "visually transparent": settings chosen so that, at normal viewing size, you would struggle to tell the original from the copy. Your original file on your own device is never touched.
What DarkDeck does
When you tick Compress before uploading, your browser (using your device's own video hardware, through a feature called WebCodecs) re-encodes the video to H.264, never larger than the original, and keeps the original audio untouched. Nothing is sent anywhere while it works. When it finishes, the upload starts by itself. You can stop at any time while it compresses, and you can save the smaller copy to your device. If a video is already small, DarkDeck skips the step.
Tech: how DarkDeck compresses
Show the technical details
Everything runs in your browser. The video file never leaves your device until the smaller version is ready.
- Read. The file is read in 8 MB slices, so a multi-gigabyte video never has to fit in memory at once. mp4box.js unpacks the MP4 or MOV container into its video and audio samples.
- Decode. The browser's
VideoDecoder(the WebCodecs API) turns the original video back into raw frames. It uses your device's video hardware where it has any. - Resize. If the target is smaller than the original, each frame is drawn onto a smaller canvas. The target height depends on the quality you pick (1080p, 720p or 480p) and never goes above the original.
- Encode. The browser's
VideoEncodercompresses the frames to H.264 at a fixed target bitrate (for example about 4.5 Mbit/s at 1080p). A key frame is written every two seconds, so seeking stays quick. If a device cannot encode H.264, VP9 is used instead, at a slightly lower bitrate. - Keep the audio. The original AAC audio is copied across untouched, so it is not re-compressed and loses no quality. Audio in other formats is not carried over yet.
- Pack. mp4-muxer writes a new MP4 with its index at the front ("fast start"), so playback begins before the whole file has downloaded. Phone rotation is preserved.
- Check. If the result is not smaller than the original, or the video was already small, the original is uploaded instead.
- Upload. The new file uploads automatically in 8 MB parts, with automatic retries, to Cloudflare R2 storage.
Why H.264?
It plays on practically every phone, TV, headset and browser, and it embeds in chat apps. Newer codecs such as HEVC and AV1 make smaller files but are not yet supported everywhere, or by every browser's encoder.
Limits
- MP4 and MOV in. WebM and MKV are not supported yet.
- One pass at a fixed bitrate. It is fast and predictable, but a two-pass or quality-based encode (like HandBrake's) can look a little better at the same size.
- Speed depends on your device. Phones and laptops with video hardware are much quicker than ones that fall back to software.
- The tab must stay open and visible while it works.