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 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: 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.

See the difference

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

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