NewsCrawler.org

H.264 Is Magic: How Video Compression Works

H.264[1] is a video compression codec standard used everywhere — internet video, Blu-ray, phones, security cameras, drones — and the result of 30+ years of work with one goal: reducing the bandwidth required to transmit full-motion video. An uncompressed video file stores each frame as a 2D buffer of pixels, 3 bytes per pixel for red, green and blue; 1080p @ 60 Hz works out to 1920x1080x60x3, or ~370 MB/sec of raw data. A 50GB Blu-ray disc would hold only ~2 mins of that, and even SSDs have trouble dumping it straight from RAM to disk. To show how effective the codec is, the author compares a 1015KB PNG screenshot of the Apple homepage with a 5-second 60fps H.264 video of the same page: 300 frames of video weigh 175KB, a fifth of the size of a single PNG frame, making H.264 roughly 1500x as efficient as PNG.

H.264 achieves this with lossy compression[2]: it throws away less important detail, so a compressed close-up of a MacBook Pro loses the holes in the speaker grills while weighing 7% of the original. An entropy encoder, a general-purpose lossless encoder, re-represents data without redundancy — like describing ten coin tosses that all landed heads as "10 tosses, all heads". Transforming an image into the frequency domain[3] places fine details in high-frequency components and gentle gradients in low-frequency ones, so masking out the high-frequency edges discards detail while the image still looks like the original; even keeping just 2% of the original information is indistinguishable unless zoomed in. This discard step is called quantization[4], and the post closes by turning to chroma subsampling, which starts from the observation that the human eye and brain are not good at resolving fine detail.

Read the original sidbala.comDiscussion

Discussion

One commenter recalls working with x264's Jason Garrett-Glaser (DarkShikari) around 2011 on slice-based multithreading patches, profiling the encoder on a 48-physical-core transcoding server used for Sony's PlayStation game streaming. After optimizing motion estimation, CPU load spread evenly and encoding speed scaled up to about 24 cores, where it had previously stalled at ~8 cores with the load piling on a single core.

Sources

Published: First seen: Читать по-русски

Open as a page