Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Canva Engineering 35 min read Deep dive mediumAdept

A journey through color space with FFmpeg - Canva Engineering Blog

Canva video exports looked less saturated than the editor because of color space mismatches when converting RGB slide images into Rec. 709 video with FFmpeg. The explanation builds from human vision (cone sensitivity, nonlinear brightness perception, higher resolution for luminance than chroma) through CIE 1931 XYZ, primaries, white points, gamma correction and chroma subsampling. It then walks through FFmpeg's colorspace filter and flags such as -colorspace, -color_primaries and -color_trc to show what each parameter does and how to transform images into correctly tagged Rec. 709 output.

Assumes: RGB pixel representationbasic video encodingFFmpeg command line

Related posts

  • Wide Gamut 2D Graphics using HTML Canvas

    WebKit mediumAdept

    WebKit now supports Display P3 color spaces for 2D canvas via getContext("2d", { colorSpace: "display-p3" }), so fills, strokes, gradients, shadows and text can use wide gamut CSS colors. Out-of-gamut colors are clamped to the canvas color space. getImageData, putImageData, the ImageData constructor and drawImage convert between color spaces, and toDataURL/toBlob embed color profiles. Code is included for detecting display, canvas and CSS Color 4 support. Remaining gaps include 8-bit-only ImageData, no HDR color spaces, and WebGL/WebGPU support.

  • Bringing HDR video to Reels

    Meta Engineering mediumAdept

    Facebook and Instagram Reels now accept HDR uploads from phone camera rolls and play them back in full HDR, which required handling HLG and PQ formats across a fragmented device landscape. Early on, HDR uploads were tone mapped to SDR on the client: Apple's native APIs on iOS, and on Android custom shaders that read the transfer function from metadata and convert YUV frames to BT.709. The server pipeline now keeps the original HDR and produces both HDR and SDR encodings using a tuned Hable tone mapping operator, doubling compute for HDR videos, which the Meta Scalable Video Processor absorbs. Because iOS dims SDR content next to HDR, Explore grids tone map videos on the fly, while Reels applies a brightness multiplier so SDR overlays render at HDR brightness and white text stays legible.

  • Add wide gamut P3 and alpha transparency to your color picker in HTML

    WebKit mediumAdept

    `<input type="color">` now supports two new optional attributes, `alpha` and `colorspace`, added to the HTML standard with WHATWG and first shipped in Safari 18.4. With `colorspace="display-p3"` users can pick from the full P3 wide gamut, `limited-srgb` keeps the old 8-bit sRGB behavior, and `alpha` adds an opacity control. The `value` attribute now accepts any CSS color syntax, such as named colors, `oklab()` or `color(display-p3 ...)`, not just hex. Older browsers fall back to an sRGB picker without opacity, and to black for unsupported value syntax, so the attributes can be used today as progressive enhancement.

  • Multi‑Ratio Video Resizing for Mobile Feed and Marketing

    Netflix TechBlog easyNovice

    Netflix automatically reframes 16:9 footage into 9:16, 4:5 and 1:1 crops with a "virtual camera" pipeline built in three stages. A neural shot-boundary detector segments the video, and Active Speaker Detection (face detection plus LipFlap) splits conversation shots into sub-shots. Faces are then ranked with saliency, speaker status and size to find a focus region, and temporal reframing locks a static crop for small motion or computes a smoothed panning path for large motion. The algorithm is built into Netflix's internal Clips tool with manual adjustment controls and XML export to Adobe Premiere, and in Netflix's internal test it outperformed Premiere's Auto Reframe on a curated evaluation set.

  • Building Background Effects for Clips

    Slack Engineering mediumAdept

    Slack's Clips background blur and image replacement run as a browser and desktop pipeline. Webcam frames are read via the Insertable Streams API on a worker thread, downscaled to 256x144, and segmented by MediaPipe's landscape selfie model compiled to WebAssembly. All compositing happens in WebGL shaders. The mask is upsampled and bilateral-filtered to smooth edges. Blur uses a mask-weighted Gaussian that also weights each sample by the mask to prevent haloing. Replacement blurs the mask most where confidence is near 0.5, thresholds it into a crisp edge, blurs the background, then alpha-blends. Edge-detection fusion was prototyped but was too unreliable on noisy or low-contrast regions to ship.

The quest for software engineering knowledge.

Look:
Layout: