MKV Optimizer: Preserve Quality While Shrinking MKV Files

MKV Optimizer Walkthrough: Settings, Tricks, and Best Practices

MKV (Matroska) is a flexible container widely used for video distribution, but large file sizes and playback issues can be frustrating. This walkthrough shows practical settings, useful tricks, and best practices to optimize MKV files while preserving quality and compatibility.

1. Goals and trade-offs

  • Primary goal: reduce file size and improve playback compatibility without noticeable quality loss.
  • Trade-offs: more compression = smaller files but higher CPU usage for encoding and potential quality loss. Aim for perceptual parity rather than bit-for-bit equality.

2. Preparation: tools and backups

  • Use a reliable MKV tool (remuxers/packagers and encoders). Common choices: an MKV-specific remuxer, ffmpeg for flexible encoding/remuxing, and a GUI front-end if needed.
  • Always keep an original backup before making lossy changes.

3. Basic workflow

  1. Inspect the file (tracks, codecs, bitrates, subtitles, chapters).
  2. Decide what to remove (unneeded audio/subtitle tracks, alternate angles).
  3. Remux if recontainerizing only (no re-encode).
  4. Re-encode video/audio only when size or format compatibility requires it.
  5. Re-multiplex tracks and test on target devices.

4. Inspecting MKV files

  • Check codecs, resolution, frame rate, bitrates, and track languages. Useful information to guide choices:
    • Video codec (H.264, H.265/HEVC, VP9, AV1)
    • Audio codec(s) (AAC, AC-3, DTS, FLAC)
    • Subtitle types (SRT, PGS/HD subtitles)
    • Chapter and attachment presence (fonts, cover art)

5. Remux vs re-encode: when to choose each

  • Remux (container change only): choose when codecs are supported by targets. Pros: lossless, fast, no quality change.
  • Re-encode: choose when you need smaller size, change codecs (e.g., H.264 → H.265), or target CPU-limited devices. Pros: smaller files; Cons: lossy, time-consuming.

6. Video optimization settings (re-encoding)

  • Preferred modern codec: H.265 (HEVC) for better compression than H.264; AV1 for best compression but slower encoding and limited device support.
  • Two recommended approaches:
    • Constant Rate Factor (CRF) — quality-based (recommended for single-pass): lower CRF = higher quality/larger file. Typical ranges:
      • H.264: CRF 18–23
      • H.265: CRF 20–28 (start ~23)
      • AV1: CRF 20–30 (slower)
    • Two-pass ABR — bitrate-targeted for strict file-size limits.
  • Encoding presets: choose slower presets for better compression (e.g., x265 slower ≈ better file-size/quality). Balance encoding time vs savings.
  • Tune resolution and frame rate only if acceptable: downscale 1080p→720p for small-screen targets; drop from 60fps→30fps if motion allows.
  • Keyframe interval and GOP: leave defaults unless targeting streaming; too long can reduce seekability.
  • Deblocking/filters: apply denoise or anti-aliasing before encoding if source is noisy; denoising often yields better compression.

Example ffmpeg command (re-encode to H.265, preserve audio/subs):

ffmpeg -i input.mkv -c:v libx265 -crf 23 -preset medium -c:a copy -c:s copy output.mkv

7. Audio optimization

  • Keep lossless audio (FLAC, DTS-HD MA) if quality-critical and storage permits. Otherwise:
    • Convert multichannel lossless to AC-3 (Dolby Digital) 384–640 kbps or AAC 192–384 kbps for reasonable stereo/5.1 quality.
    • For spoken-content, lower bitrate (96–128 kbps) is often acceptable.
    • Use stereo downmix for single-speaker content to save space.
  • When preserving multiple language tracks, consider keeping one high-quality main track and secondary tracks at reduced bitrate.

Example ffmpeg audio convert:

ffmpeg -i input.mkv -c:v copy -c:a aac -b:a 192k output.mkv

8. Subtitles and attachments

  • Prefer text-based subtitles (SRT, ASS) over image-based (PGS) for tiny size and style flexibility. Convert PGS to SRT when possible (note: OCR required and may lose styling).
  • Remove unused subtitle tracks and attachments (

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *