FFmpeg: The Incredible Technology Behind Video on the Internet | Lex Fridman Podcast #496
Overview
Jean-Baptiste Kempf and Kieran Kunhya explain how FFmpeg, VLC, and related projects make modern audio and video work, from container parsing and perceptual compression to handwritten SIMD assembly and ultra-low-latency streaming. They argue that this volunteer-built infrastructure depends on rigorous engineering, open licensing, and sustained support, highlighting projects such as x264 and dav1d, the challenges of maintaining software used at global scale, and FFmpeg’s role in preserving multimedia for the future.
Key takeaways
- FFmpeg and VLC succeed through complementary roles: FFmpeg supplies codec, container, and filter infrastructure, while VLC exposes that capability through a resilient player and helps test unusual real-world media.
- Lossy video compression is optimized for human perception, not exact reconstruction: techniques such as YUV color subsampling, motion prediction, and psychovisual rate-distortion can reduce file size while preserving what viewers notice.
- Handwritten SIMD assembly remains valuable in high-volume decoding paths: VideoLAN’s dav1d uses about 240,000 lines of assembly and can decode 720p AV1 on one or two CPU cores.
- Open-source licenses are operational choices: LGPL enabled libVLC integration into closed-source products, while GPL and AGPL impose stronger sharing requirements on derivatives.
- A globally critical open-source dependency can still have only a handful of maintainers, so organizations that rely on FFmpeg should contribute patches, sustained funding, and realistic support expectations.
- FFmpeg’s archival work, including the lossless FFV1 codec, helps preserve recordings in formats that can remain accessible even after their original software and hardware disappear.
Chapters
- Jean-Baptiste Kempf and Kieran Kunhya emphasize that FFmpeg reviews contributions by code quality, not a contributor’s identity or employer.
- Kunhya describes FFmpeg as an enormous CPU user, while Kempf notes that dav1d contains about 240,000 lines of handwritten assembly.
- The opening frames assembly optimization as consequential because billions of devices decode video continuously.
- Lex Fridman introduces FFmpeg as infrastructure behind services and software including YouTube, Netflix, Chrome, Discord, and VLC.
- FFmpeg processes and converts media; VLC is a free, open-source player that supports a wide range of formats and platforms.
- Kempf leads VideoLAN, while Kunhya is a codec engineer and FFmpeg contributor.
- VLC can record VHS through capture cards and supports unusual media, including DVD-Audio and game-specific codecs.
- VideoLAN contributors tested deliberately bizarre files, including an MKV with changing resolution and rotation and a video made from animated subtitles.
- The orange traffic-cone logo is so recognizable that some users search for cone player to find VLC.
- A player first obtains a byte stream from a source such as an HTTP URL, a local file, or a DVD.
- Demuxing separates container data into video, audio, and subtitle tracks before each track is decoded.
- Decoded images go to the graphics system and display, while audio is sent to an audio device for playback.
- Players determine whether a codec and its variant can be decoded by a particular GPU, then use software decoding when hardware support is unavailable.
- Software decoding can involve entropy decoding, intra prediction, residual reconstruction, inverse transforms, and motion compensation.
- Kempf explains that lossy codecs exploit human perception, including YUV color representation and reduced color resolution.
- Containers such as MP4, MOV, AVI, and Matroska package tracks; codecs such as H.264 encode or decode media within them.
- H.264 is also called AVC and MPEG-4 Part 10, a naming tangle that makes it easy to confuse the codec with the MP4 container.
- FFmpeg and VLC probe a file’s contents rather than trusting its extension, which serves only as a clue for choosing a demuxer.
- VLC originated in a VideoLAN network-streaming project where UDP packets could be lost, so resilience to damaged input became a design principle.
- VLC often attempts to interpret incomplete or malformed files rather than stopping at the first error.
- This behavior helped with AVI files whose metadata could be missing during a partial download.
- FFmpeg provides libraries for codecs, muxers, demuxers, and filters, alongside command-line tools such as ffmpeg and ffprobe.
- Its configurable command line can combine media, apply filters, add captions, and crossfade audio and video.
- Kempf compares its command-line breadth to a media-processing language capable of building complex workflows.
- FFmpeg, VLC, x264, and VideoLAN are open-source projects that publish code and permit others to inspect, modify, and reuse it under their licenses.
- Kempf compares open source to sharing a cheesecake recipe and explaining how to build the oven, not merely selling the finished cake.
- Accessible software tools helped move video production from specialized equipment costing hundreds of thousands of dollars to ordinary computers.
- Permissive licenses such as MIT and BSD allow broad reuse, while copyleft licenses such as GPL and AGPL impose requirements on derivatives.
- LGPL permits use in some closed-source applications while requiring changes to the library itself to be shared.
- Kempf describes licensing as a community’s shared social contract and notes that license choices can enable or restrict forks and commercial use.
- Kempf changed libVLC’s core license from GPL to LGPL so third-party apps, including commercial games, could integrate the playback engine without opening all their code.
- A legitimate relicensing required contacting more than 350 contributors because each retained copyright to their contributions.
- Kempf recounts tracking down a contributor’s father after the contributor had died, illustrating the human responsibilities involved in relicensing.
- Kempf says a small core team must maintain code long after most contributors move on, so patches need to be excellent and maintainable.
- The core groups are roughly five people for VLC and 10 to 15 for FFmpeg, despite thousands of historical contributors.
- Review focuses on the patch rather than the contributor’s title, nationality, or background.
- FFmpeg and VLC’s technical subcultures can use terse criticism, especially when maintainers need to review complex patches without extensive handholding.
- Kempf notes that many contributors are not native English speakers, so tone and phrasing can be misread across cultures.
- The guests distinguish criticism of code from personal attacks and stress the need to preserve quality.
- Kempf says he turned down offers worth tens of millions of dollars rather than add shady advertising, toolbars, spyware, or browser changes to VLC.
- He says the decision reflected a desire to earn money ethically and to protect the project’s trust and purpose.
- VLC grew from the VideoLAN student project, which began as a university experiment in streaming satellite television across a campus network.
- The Network 2000 project streamed MPEG-2 satellite television over a fast campus network, years before YouTube.
- VideoLAN emerged from that work, became open source in 2001, and Kempf joined in 2003 before helping establish the VideoLAN nonprofit.
- Kempf says the project was close to dying in 2005, when only two developers were active.
- Kempf rejected ad deals that would compromise VLC’s trust, while Kunhya describes growing concern about companies treating volunteer projects like contracted vendors.
- FFmpeg’s public bug tracker is for reporting problems, not an automatic service-level agreement for a trillion-dollar company.
- Kunhya says donations increased after public discussions but still did not fund even one full-time developer.
- Kunhya criticizes Google for using AI to generate security reports on FFmpeg and publicizing the work before maintainers could address the findings.
- One report concerned an obscure 1990s game codec, but its severity and urgency were presented as if every issue were a major threat.
- The guests argue that large-scale vulnerability discovery should be matched by patches, funding, and consideration for volunteer capacity.
- Kunhya says Microsoft Teams requested urgent FFmpeg maintenance and offered a one-time payment of a few thousand dollars rather than a long-term support contract.
- The XZ backdoor incident illustrates how pressure and isolation can overwhelm a single unpaid maintainer.
- Kempf says company open-source program offices should explain internally that community projects are not ordinary suppliers.
- Kunhya says criticism on X increased awareness of FFmpeg and raised donations, although not enough to support a full-time developer.
- Kempf says public escalation helped resolve a year-long VLC update problem with the Android Play Store and other distribution issues.
- Both encourage users to follow and financially support FFmpeg and VideoLAN.
- FFmpeg and VideoLAN have accepted contributors who began programming as teenagers, including developers who wrote assembly for x264 and VLC.
- Kempf cites a 14-year-old Google Summer of Code participant and a 16-year-old contributor as examples of open access to real projects.
- The guests say contributors can learn C, assembly, and rigorous review through code used by millions of people.
- Kempf recommends working on a subject contributors love, citing anime and movies as routes into multimedia projects.
- FFmpeg offers practical training in C, assembly, computer architecture, SIMD, CPU pipelines, and performance optimization.
- Contributors can see their work affect everyday playback for hundreds of millions of people.
- Kunhya compares VLC’s relationship to FFmpeg to Android’s relationship to Linux: each depends on the other while serving a different role.
- VLC uses FFmpeg for decoding and gives it exposure to unusual files, while VideoLAN’s x264 encoder helped popularize FFmpeg pipelines.
- Both projects rely on a broader ecosystem of libraries, including Opus and other media components.
- Fabrice Bellard created FFmpeg, and Michael Niedermayer became a central contributor in the 2000s.
- Niedermayer added broad support for DivX, Xvid, MPEG-4 Part 2 variants, Windows Media, and RealMedia.
- One reliable open-source player replaced the need for multiple proprietary players and questionable codec packs.
- Kostya Shishkov reverse-engineered difficult proprietary codecs, including GoToMeeting formats, by treating compiled binaries as a specification.
- The work could begin by locating a proprietary decoder, extracting decoded YUV output, and using that output as a reference.
- A suitable sample file can simplify the first steps by exposing a narrow set of codec tools before broader cases are implemented.
- Reverse engineers inspect machine code, trace branches and memory, and infer operations such as DCT transforms and entropy decoding.
- Kieran Kunhya describes reverse-engineering CineForm by starting with an animation sample that contained simple flat blocks.
- Some codec investigations require virtual machines, memory dumps, and debugging encrypted or DRM-protected playback paths.
- Modern codecs generally require independent decoders to produce identical output for the same input sample.
- FFmpeg’s FATE system tests codecs and filters across combinations of operating systems, compilers, architectures, and instruction sets.
- Volunteer-run test machines can catch compiler miscompilations that produce visual glitches or cascading frame errors.
- Kunhya describes handling 10-bit video, where CPUs often store samples in 16-bit values and waste six bits without specialized packing.
- Kempf says VLC supports platforms from Windows XP and macOS 10.7 through current versions, plus BSD, Solaris, and even OS/2.
- Keeping VLC usable on older devices can spare users from replacing hardware that still works.
- SIMD means single instruction, multiple data: one operation can process a vector of pixel values rather than one value at a time.
- Kunhya says handwritten assembly in selected FFmpeg routines can outperform C by large multiples, including a demonstrated 62-times speedup.
- The contributors choose direct assembly rather than relying on compiler intrinsics for performance-critical routines.
- VideoLAN’s dav1d decoder combines roughly 30,000 lines of C with about 240,000 lines of handwritten assembly.
- Kempf says a single CPU core or two can decode 720p AV1, reducing dependence on hardware decoders.
- The decoder matters at scale as AV1 reaches substantial shares of Netflix and YouTube video.
- The guests challenge the assumption that compiler auto-vectorization can match carefully tuned SIMD assembly across real CPUs.
- FFmpeg and dav1d select optimized functions at runtime after detecting the processor’s instruction-set capabilities.
- Handwritten assembly can also use custom calling conventions inside a library to avoid unnecessary register saves and loads.
- Kempf argues that hardware limits, power costs, and rising compute demand make software efficiency increasingly valuable.
- The comparison to LLM quantization illustrates optimizing around constraints such as memory, bandwidth, and available hardware.
- Low-level work is most worthwhile in frequently executed paths, such as AV1 decoding on billions of devices.
- Kunhya’s assembly lessons teach practical vector-processing tasks rather than beginning with an exhaustive list of instructions.
- The prerequisites are high-school mathematics and basic C concepts, especially pointers.
- The lessons aim to scale knowledge that FFmpeg contributors traditionally passed from one assembly programmer to another.
- Kunhya values Rust’s memory-safety model but argues it must match existing projects’ features, testing, ABI stability, and reliability.
- Kempf says Rust works especially well for new projects and parsing or networking code, but can be difficult to integrate into mature C systems.
- Both warn that rewrites often reach 80 or 90 percent quickly, while the final edge cases and compatibility requirements consume most of the work.
- Kempf points out that Rust cannot guarantee memory safety across handwritten assembly that can access arbitrary addresses.
- He suggests instrumenting assembly during compilation to check memory access, drawing a parallel with VideoLAN’s checkasm testing tools.
- Understanding registers, cache levels, RAM, and storage makes programmers better equipped to reason about performance and safety.
- FFmpeg and Libav split after disagreements over governance and development processes, while open-source licensing allowed both projects to continue.
- Kempf says developers and useful changes eventually returned to FFmpeg, leaving it stronger than before the fork.
- The guests describe forks as a way to challenge a project’s status quo, while acknowledging the personal toll of conflict.
- Kempf identifies maintainer burnout as a serious problem, especially when maintainers face low-quality reports and patches at scale.
- The XZ incident showed how a lone maintainer could be pressured into granting access to an attacker.
- The guests point to dependencies such as FFmpeg, XZ, and libxml as critical infrastructure with surprisingly small maintenance teams.
- Kempf recounts receiving a threatening letter and powder after ending VLC support for PowerPC around 2009 or 2010.
- He says appreciative messages from users help validate volunteer contributions and are shared with the VideoLAN community.
- The guests urge users to thank and celebrate the people who maintain open-source software.
- Kunhya began with Microsoft QBasic on Windows 3.1 and Windows 95, then dreamed of building a football video game.
- Kempf learned BASIC and Turbo Pascal before using Logo’s on-screen turtle to draw programmed shapes as a child.
- Both connect early experimentation to a lasting desire to build useful, technically challenging tools.
- H.264 became widely adopted as HD video and sufficiently fast Intel CPUs made real-time encoding more practical.
- x264’s developers emphasized psychovisual quality rather than optimizing only peak signal-to-noise ratio, which can favor visually blurry results.
- The ParkJoy test sequence challenges encoders with grass, water, trees, reflections, and motion.
- x264 contributors used visual feedback to tune encodes for everyday screens, rather than relying exclusively on expensive reference displays.
- Anime posed distinctive compression problems, including gradients, banding, stylized textures, and complex subtitles.
- Kunhya describes x264 as a reference point against which newer encoders such as AV1, AV2, and VVC are compared.
- Kempf estimates that AV1 can reduce bandwidth by roughly 40 to 60 percent compared with H.264 at similar visual quality.
- Newer codecs add tools and search choices, improving compression while making encoding much more computationally expensive.
- YouTube can encode popular videos with AV1 because a costly server encode can save bandwidth and battery across millions of plays.
- An I-frame is a complete image, while P-frames reuse earlier image data and encode changes.
- B-frames can depend on frames both before and after them, so decoding order can differ from display order.
- ProRes is an intra-only editing codec that avoids temporal dependencies to support fast seeking and cuts.
- Media teams tune bitrate, quality, resolution, frame rate, GOP length, and B-frame count for different content types.
- YouTube must encode uploads at multiple resolutions and make less popular videos available without delay.
- The guests note that viewers often notice audio-quality changes more readily than gradual shifts in video quality.
- Google Video once embedded VLC in Internet Explorer through an ActiveX plugin.
- The modern inverse is VLC and FFmpeg compiled to WebAssembly so media playback can run inside a browser’s JavaScript environment.
- Kunhya describes YouTube as a large-scale counterpart to VLC because it must ingest, encode, and serve diverse video.
- WikiLeaks’ Vault 7 documents described a modified VLC distribution that added a DLL to collect documents and transmit them.
- Kempf says other attackers reused VLC components in malware, which led to VLC being temporarily banned in India.
- Users should obtain VLC only from the official VideoLAN website because search results and fake installers can distribute spyware.
- VLC includes around 500 plugins, along with code from FFmpeg and hardware drivers that can contain bugs.
- Kempf describes a design that separates demuxing, decoding, and filtering into sandboxed processes.
- Unlike a simple document viewer, a media sandbox must handle high-throughput video and large volumes of memory transfer.
- A high-school math teacher’s VLC puzzle filter lets users turn video into a movable jigsaw, with the piece limit raised after a user complained.
- VLC can output video as ASCII characters, which can help diagnose a multicast stream over SSH on a router.
- Kempf says a player used by hundreds of millions of people will eventually have users for even obscure features.
- Adaptive streaming lets a player switch among pre-encoded resolutions when network congestion slows segment downloads.
- Satellite and live broadcasting impose tighter real-time and bandwidth constraints than ordinary on-demand playback.
- A player can lower quality when a segment takes too long to download, but deciding when to increase quality is a more delicate control problem.
- Kempf’s Kyber project targets interactive video for controlling drones, robots, cloud games, and remote machines.
- Kyber sends video, audio, and control inputs over one encrypted QUIC connection based on UDP.
- Synchronized camera and sensor streams are important for both real-time operation and consistent robotics training data.
- Glass-to-glass latency measures the time from a camera capturing an event to the image appearing on a remote display.
- Kempf sets a four-millisecond goal and reports an achieved Windows-to-Windows or Windows-to-Mac result of about seven milliseconds.
- An NVIDIA encoder and Intel decoder can together account for roughly six milliseconds, leaving little time for the network.
- Kyber uses a dual-license model: AGPL for open-source use and a commercial license for companies that keep their products closed.
- A demonstration remotely controlled a small rover from France using a webcam and a compact server.
- Kempf describes forward error correction as a way to reconstruct some lost packets without waiting for retransmission.
- Kempf describes AV2 as the next Alliance for Open Media codec after AV1, with an estimated 30 percent bandwidth reduction at similar quality.
- The current AV2 encoder is called AVM, while the planned VideoLAN decoder is referred to as dav1d2.
- H.265 is HEVC and H.266 is VVC; the guests use roughly 30 percent better compression per generation as a broad rule of thumb.
- Codec patents can cover individual techniques, and MPEG LA and HEVC Advance assembled patent pools for standards such as HEVC.
- Kempf says fragmented HEVC licensing could expose large streaming platforms to costs of hundreds of millions of dollars per year.
- The Alliance for Open Media developed AV1 and AV2 to provide strong compression with a goal of avoiding patent royalties.
- Kempf argues that France’s rejection of software patents helped VideoLAN distribute VLC without prohibitive licensing costs.
- He says intelligence agencies twice asked for a VLC backdoor and were refused; the project would shut down rather than compromise its software.
- VideoLAN builds and signs releases with strong controls, including offline build machines and multiple signatures.
- VLC does not collect telemetry or tell VideoLAN what files people play, so the project cannot report individual viewing activity.
- Kempf says VideoLAN has helped authorities troubleshoot playback without receiving the underlying media files.
- He describes VLC as an offline tool rather than a content-hosting platform.
- Kempf says he used to feel stress about VLC’s visibility and legal pressure but now focuses on whether his actions harm anyone.
- His worst-case test is whether a project failure or legal dispute threatens life or causes real harm.
- He reasons that source code can survive through its open-source copies even if an organization or website disappears.
- The archival community treats FFmpeg as a way to preserve media that might otherwise become unplayable, as happened with BBC Microcomputer-era records.
- FFV1 is a lossless codec developed for archival needs, including efficient software encoding and recovery from damaged storage.
- Archivists contribute specialist knowledge about historical tape formats, colorimetry, and the risks of losing visual detail.
- Archivists face a shrinking supply of equipment that can read older tape, forcing difficult choices about what to digitize.
- Lossless storage protects details that may appear insignificant until a later viewer notices something important in the frame.
- Kunhya suggests C and FFmpeg could remain understandable far into the future, much like a durable technical language.
- Kempf expects multimedia frameworks to handle more than conventional audio and video, including point clouds, volumetric video, depth data, and XR.
- VLC already has VR and XR work, while Kyber targets interactive low-latency streams for devices such as headsets and robots.
- He argues that new time-synchronized sensory data, potentially including haptics or other modalities, could fit multimedia pipelines.
- Kempf says a new technology area often begins with competing standards and moves toward standardization as the market matures.
- VideoLAN has worked on spatial-audio and haptic plugins, with architecture designed to make future modules easier to add.
- He describes multimedia broadly as timed digital streams that represent human senses.
- FFmpeg has been used by NASA’s Mars 2020 rover to compress images using largely commercial off-the-shelf technology.
- VLC has been used in Formula 1 paddocks, by the European Space Agency, and at CERN to stream camera feeds across the Large Hadron Collider site.
- Kempf recalls fixing a CERN multicast-streaming problem during a visit to the 27-kilometer collider ring.
- Kunhya favors the motto talk is cheap, send patches, and says FFmpeg’s reach extends to applications such as the Mars rover.
- Kempf says he does not regret past decisions, arguing that people should learn from mistakes rather than dwell on them.
- The closing cites Linus Torvalds’s view that many programmers create software because programming is fun.
Transcript excerpt
0:00 - The important is, is your code good? We care about excellent code. We don't care who you are. Like maybe you're a dog. I don't care, right? I don't care where you come from. I need to look at your code. Oh, yeah, but I'm an engineer at this very large company in Italy, in Germany, in the US. We don't care. We care about the quality of your code because this is what defines our community and which means that we have a lot of people who contribute who are some very different backgrounds and very introverted. Sure. But that's okay, right? - FFmpeg is probably one of the biggest CPU users in the world. Everything we've just said in the past couple of minutes, every sentence is someone's lifetime's work. There are books about every sentence. So the level of complexity in many cases is inordinate. - FFmpeg has one hundred thousand lines of assembly for all the codecs.
0:50 - For all codecs. Mm-hmm. - And just this one has two hundred and forty thousand. Every cycle matters. We are talking about probably three billion devices which are going to decode video nonstop because, for example, thirty percent of the video from Netflix is now in AV1, fifty percent of YouTube. - This is what peak video codecs should look like. Seventy-nine point nine percent assembly, nineteen point six percent C, and zero point five percent other. - And what's incredible is with those tweets, which is factual, people get crazy. - For the last two years, they go crazy. No, intrinsics is fine. The compiler- - You can optimize your compiler. Auto-vectorization, it's your fault. You don't understand. And we've tried that forever, right? - For two years, and two years later, showing hundreds of examples
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Lex Fridman.