mediacodec.dev

Independent · Open-source focused

Media engineering,
explained.

Independent tools and plain-English education for developers who ship video and images. No vendor agenda, just how this stuff actually works.

Compress a video

ffmpeg 8.x

Codec

Quality (CRF)

bettersmaller23

CRF 23: H.264's default, chosen by its authors as the sweet spot for most content.

ffmpeg -i input.mp4 \
  -c:v libx264 -crf 23 \
  -preset medium -c:a copy \
  output.mp4

Also covered: convert to mp4, convert to webm, resize video, trim & cut, crop video, extract audio, remove audio, rotate video, cap frame rate, extract a frame, watermark.

The wiki

The concepts underneath the commands, written for developers who need to make a decision, not pass an exam.

01 Transparency in video Which video codecs can carry an alpha channel, why MP4 usually cannot, and the tricks used when it cannot. 02 Aspect ratio, SAR and DAR Why a video plays stretched in one player and correct in another, and what the three aspect ratios in every file actually mean. 03 Audio codecs: AAC, Opus, MP3 and the lossless ones Which audio codec to use for video, for the web and for archives, and what bitrate is actually enough. 04 Bit depth and banding Why 8-bit video bands in skies and gradients, and why encoding in 10-bit helps even when the source and the screen are both 8-bit. 05 I-frames, P-frames and B-frames The three kinds of frame every video codec uses, why B-frames save so much, and what they cost you in latency and seeking. 06 Hardware vs software encoding Why NVENC is twenty times faster than x264 and still makes bigger files, and how to choose between them. 07 HDR video: PQ, HLG and the metadata problem What HDR actually changes in the signal, why HDR content looks grey on SDR screens, and which of the four formats you need. 08 Low-latency live streaming Where the seconds of delay in a live stream actually come from, and what LL-HLS, CMAF and WebRTC each buy you. 09 Codec profiles and levels Why a valid H.264 file refuses to play on a TV, and what profile, level and tier actually constrain. 10 Subtitles and captions Soft subs, hard subs and burned-in text: which format survives which container, and when to give up and render the words into the pixels. 11 Measuring video quality: PSNR, SSIM and VMAF What each quality metric actually measures, why PSNR misleads, and how to use VMAF without fooling yourself. 12 What the browser can do without FFmpeg A capability map of browser-native video processing in 2026: what WebCodecs genuinely replaces, what still needs FFmpeg, and where the line actually sits. 13 Adaptive bitrate streaming: HLS, DASH and the ladder How one video becomes dozens of files, why keyframe placement decides whether it works, and what HLS and DASH actually differ on now. 14 Choosing an image format: JPEG, WebP, AVIF and JPEG XL What each format is genuinely good at, what browsers really support in 2026, and a delivery decision that survives contact with production. 15 Colour spaces, and why your video looks washed out Rec.709, limited vs full range, and the tagging mistakes that drain the contrast out of an export without touching a pixel. 16 Containers vs codecs: MP4, WebM and MKV Why .mp4 tells you almost nothing about a file, which codec goes in which container, and why changing container is usually free. 17 Rate control: CRF, CBR, VBR and two-pass The four ways to tell an encoder how many bits to spend, what each one guarantees, and which job each belongs in. 18 Chroma subsampling: 4:2:0 vs 4:2:2 vs 4:4:4 Why video throws away three quarters of its colour information, why you almost never notice, and when you absolutely do. 19 Keyframes and GOP size: what GOP length does in H.264, HEVC and AV1 I, P and B frames, what a Group of Pictures is, and why keyframe placement decides how your video seeks, streams and cuts. 20 Understanding CRF (constant rate factor): quality-targeted encoding What Constant Rate Factor actually does, why it beats fixed bitrates for files, and what the numbers mean in x264, x265, VP9 and AV1.

Run the numbers

Back-of-envelope calculators with every assumption stated and every price sourced.

And for the encode itself: video bitrate, file size, resolution & aspect ratio and bits per pixel.

See the difference

Codec debates end faster with pixels and numbers on the same page.

01 H.265 vs H.264 The most common upgrade question, answered at equal bitrate: what HEVC buys over AVC, and what it costs in playback reach. 02 AV1 vs H.264 The same clip at the same bitrate, two codec generations apart. VMAF-scored. 03 AV1 vs H.265 The two modern codecs head to head: the royalty-free one against the licensed one, same budget, same frames. 04 VP9 vs H.264 The WebM codec against the MP4 baseline: how much VP9 saves, and why YouTube has shipped it for a decade. 05 JPEG vs WebP vs AVIF vs JPEG XL Four image formats, one byte budget. Drag the slider; the metrics are underneath. 06 AVIF vs WebP The two formats every browser now decodes, at the same byte budget: where AVIF pulls ahead and where WebP holds its own. 07 JPEG XL vs AVIF The two next-generation image formats compared on the same bytes, with the browser-support reality stated plainly. 08 What your browser decodes A live probe of the browser you are using right now: image formats, playback, WebCodecs. 09 Stream inspector See what a video file really is: every encoded packet on a timeline, keyframes standing tall, and a preview that seeks the way seeking actually works. 10 Quantizer lab The knob under every codec: scrub a quantizer and watch a frame from your own video degrade, live, with what was thrown away made visible. 11 Video transcode lab Convert video with your machine's hardware encoders, straight from the browser: MP4, WebM, resize, trim, audio extraction. 12 Chroma subsampling lab Split an image into luma and chroma, apply 4:2:0 for real, and watch red text bleed while white text stays crisp. 13 Washed-out colour lab Reproduce the washed-out export on demand: decode a frame with the wrong matrix or range, and measure exactly how far the colour moved. 14 Encoder benchmark Race every codec your browser can encode on identical frames, and see which ones your machine has silicon for. 15 Image codec lab Encode your images to JPEG, WebP, AVIF and JPEG XL with real wasm codec builds, live.

New tools and articles land regularly. Catch them on X or by RSS.