How Facebook encodes your videos
Apr 5, 2021Taein Kim, Ploy Temiyasathit, Haixiong Wang

Summary
This post details the evolution of Facebook's video encoding system, moving from a rule-based prioritization to a benefit-cost model combined with an ML model to predict watch time. This new approach optimizes the use of advanced codecs (like VP9) and expensive encoding recipes for videos predicted to be highly watched, thereby improving visual quality, reducing buffering, and managing compute resources more efficiently. The benefit-cost model defines benefit as (compression efficiency) * (predicted watch time) and cost as the compute required for missing encodings, with priority being Benefit/Cost. The ML model predicts watch time based on uploader history, video metadata, and past popularity trajectories.