---
title: "How Facebook encodes your videos"
description: "Facebook prioritizes advanced video encodings (VP9, slower H264 recipes) by a Benefit/Cost score instead of hard-coded rules."
url: "https://swe.quest/articles/how-facebook-encodes-your-videos-a25a3c51f5bfb7c5"
canonical: "https://engineering.fb.com/2021/04/05/video-engineering/how-facebook-encodes-your-videos/"
source: "Meta Engineering"
published: "2021-04-05"
difficulty: "medium"
kind: "Case study"
reading_minutes: 12
tags: ["video-media","machine-learning","scheduling","cost-optimization"]
---

# How Facebook encodes your videos

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2021-04-05, 12 min read, Case study. Original: [https://engineering.fb.com/2021/04/05/video-engineering/how-facebook-encodes-your-videos/](https://engineering.fb.com/2021/04/05/video-engineering/how-facebook-encodes-your-videos/)

## Summary

Facebook prioritizes advanced video encodings (VP9, slower H264 recipes) by a Benefit/Cost score instead of hard-coded rules. Benefit is relative compression efficiency at fixed quality, measured by Minutes of Video at High Quality per GB (MVHQ), multiplied by effective predicted watch time adjusted for device codec support. Cost is the normalized compute needed to finish the missing lanes of an encoding family, so priority rises as a family nears deliverability. Next-hour watch time comes from two ML models, one at upload time using creator history and one at view time using the video's watch trajectory. These are trained on rebalanced event data and evaluated with RMSE, MAPE, per-category metrics and threshold-based false positive/negative rates.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Video & media](https://swe.quest/tags/video-media.md) (Domains)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Scheduling](https://swe.quest/tags/scheduling.md) (Distributed systems)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)

## Prerequisites

- video codecs basics ([easy posts on Video & media](https://swe.quest/tags/video-media.md?difficulty=easy))
- adaptive bitrate streaming ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))
- regression model evaluation ([easy posts on Evaluation](https://swe.quest/tags/evals.md?difficulty=easy))

## Keywords

VP9, H264, adaptive bitrate streaming, MVHQ, Facebook

## Related posts

- [Reducing Instagram’s basic video compute time by 94 percent](https://swe.quest/articles/reducing-instagram-s-basic-video-compute-time-by-94-percent-8efd07bfee25d57c.md): Meta Engineering · 2022-11-04 · Medium · 5 min read · Video & media, Cost optimization, Capacity planning, Performance engineering
  Instagram cut the compute cost of its basic adaptive bit rate (ABR) video encodings by 94 percent by reusing the frames from its progressive encodings and repackaging them into a DASH-capable file structure instead of transcoding from the original upload.
- [Adopting AV1 for Real-Time Communication (RTC) at Scale](https://swe.quest/articles/adopting-av1-for-real-time-communication-rtc-at-scale-c700b86b1446a111.md): Meta Engineering · 2026-06-22 · Medium · 18 min read · Video & media, Communications, Mobile, Performance engineering
  Meta now runs AV1 for real-time video calls on most mobile devices in Messenger and WhatsApp.
- [Inside Facebook’s video delivery system](https://swe.quest/articles/inside-facebook-s-video-delivery-system-d5975357617c95f8.md): Meta Engineering · 2024-12-10 · Medium · 13 min read · Recommendations & ranking, Video & media, System design, Mobile, Refactoring & migrations
  Facebook spent roughly two years unifying its separate Watch and Reels stacks across mobile clients, the server layer and ranking, in a deliberate order.
- [How Meta brought AV1 to Reels](https://swe.quest/articles/how-meta-brought-av1-to-reels-f3c22ae15f525134.md): Meta Engineering · 2023-02-21 · Medium · 12 min read · Video & media, Mobile, Performance engineering
  Meta deployed AV1 encoding and delivery for Facebook and Instagram Reels, using SVT-AV1 for encoding and the dav1d software decoder on iOS and Android because most phones lack AV1 hardware decoders.
- [Better video for mobile RTC with AV1 and HD](https://swe.quest/articles/better-video-for-mobile-rtc-with-av1-and-hd-7dfda60dab6d29eb.md): Meta Engineering · 2024-03-20 · Medium · 14 min read · Video & media, Communications, Mobile, Performance engineering
  Meta improved 1:1 mobile RTC video in Messenger, Instagram and WhatsApp by moving from H.264 to software AV1 for low-bandwidth calls (under 300 Kbps).

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
