FFmpeg · Anime · Encoding Reference

Encoding anime
the right way.

Practical FFmpeg settings for archiving and re-encoding anime — HEVC NVENC, 10-bit color, audio copy logic, scale filters that actually work, and GPU preset tradeoffs. Built from personal testing against BDRip and WEB-DL sources.

← Back to ffmpeg Encode
// Contents
  1. Why HEVC over H.264
  2. 10-bit encoding and pix_fmt
  3. CRF / CQ quality settings
  4. GPU presets (NVENC p1–p7)
  5. Scale filters — doing it correctly
  6. Audio — copy vs re-encode
  7. Color range
  8. The full recommended command
  9. CPU fallback (no NVIDIA)

Why HEVC over H.264

For anime storage and playback, HEVC (H.265) consistently outperforms H.264 at equivalent visual quality. Flat colors, clean linework, and large uniform areas — the dominant visual language of animation — compress exceptionally well under HEVC's larger prediction block sizes.

In practical terms: a 500 MB BDRip episode that re-encodes to ~130 MB with H.264 at CRF 22 will reach the same quality at ~90–110 MB under HEVC at CQ 24. The gap widens at lower bitrates. For a library of hundreds of episodes, this compounds significantly.

Hardware support is no longer a concern. Every major platform — Apple TV 4K, Jellyfin, Plex, Infuse, VLC, mpv — decodes HEVC natively. The only remaining reason to use H.264 is compatibility with very old devices or specific streaming service upload requirements.

✓ Use HEVC when
  • Building a personal anime archive
  • Targeting Apple TV, Jellyfin, or Infuse playback
  • Storage efficiency matters
⚠ Stick with H.264 when
  • Uploading to services with H.264-only requirements
  • Targeting very old devices (pre-2016 hardware)
  • Client-side software decoding only and CPU is weak

10-bit encoding and pix_fmt

Most BDRip anime sources are encoded in 10-bit color (yuv420p10le). Re-encoding to 8-bit introduces banding — subtle but visible color stepping in gradients, skies, and dark scenes. Anime is especially prone to this because of its reliance on smooth gradient fills and subtle shading.

When targeting HEVC main10 profile, the pixel format must be yuv420p10le. These two settings are coupled — using the wrong pix_fmt for a given profile either produces an error or silently degrades quality.

Profile Correct pix_fmt Bit depth Notes
main yuv420p 8-bit Broadest device compatibility
main10 yuv420p10le 10-bit Recommended for anime BDRip sources
main12 yuv420p12le 12-bit Rarely needed; limited hardware decode support
⚠ Common mistake

Setting -profile:v main10 but leaving -pix_fmt yuv420p (8-bit). FFmpeg may silently encode 8-bit data into a 10-bit container, wasting bitrate and producing incorrect output. Always match them.

// Correct 10-bit pairing
-profile:v main10 -pix_fmt yuv420p10le

CRF / CQ quality settings

NVENC uses -cq (Constant Quality) rather than -crf. The scale is similar — lower numbers mean higher quality and larger files — but NVENC's CQ is not a 1:1 match to x265's CRF. NVENC at CQ 24 is roughly equivalent to x265 CRF 20–22 in terms of output size, though quality characteristics differ.

For anime specifically, the flat regions and clean lines mean you can push CQ higher (lower quality number) than you might for live action without visible degradation. The gains from going below CQ 20 are rarely worth the file size increase.

CQ Value Use case Typical output size*
18–20 Near-lossless archive Large — diminishing returns
22–24 High quality, reasonable size ~15–25% of source BDRip
26–28 Balanced — daily driver ~10–18% of source
30–32 Compact / mobile storage ~7–12% of source

* Percentages vs a typical 1080p BDRip HEVC source. Results vary by content and source encoder.

ℹ Note on source quality

Re-encoding a compressed source (BDRip, WEB-DL) never recovers lost quality — it only adds another generation of compression. If your source is already HEVC at a reasonable bitrate, consider whether re-encoding is worth it at all vs just keeping the source.


GPU presets (NVENC p1–p7)

NVENC presets range from p1 (fastest, lowest compression efficiency) to p7 (slowest, best compression). Unlike x264/x265 presets which vary the encode quality, NVENC presets primarily control how aggressively the encoder searches for optimal block matches — the quality ceiling is still set by CQ.

On a laptop 4060 specifically, p6 is the practical sweet spot. p7 adds meaningful encode time for diminishing compression gains at typical anime CQ values. p4 is fine for quick turnarounds when you're batch-processing overnight isn't an option.

p4 — Faster
Good for quick batches
-preset p4
p5 — Balanced
Default starting point
-preset p5
p7 — Max Quality
Diminishing returns vs p6
-preset p7
ℹ Desktop vs Laptop GPU

Desktop RTX cards (3080, 4080, etc.) have a higher NVENC throughput ceiling — p7 is more viable there. On laptop GPUs the thermal and power constraints mean p6 often encodes at similar speed to p7 in practice, with p7 occasionally throttling under sustained load.


Scale filters — doing it correctly

The goal for most anime archives is: cap at 1080p, never upscale, preserve aspect ratio. Getting the scale filter wrong is one of the most common FFmpeg mistakes.

The wrong way — comparing a constant against itself:

// ❌ No-op: min(1920,1920) always = 1920
-vf "scale=min(1920\,1920):min(1080\,1080):force_original_aspect_ratio=decrease"

The right way — using iw and ih, FFmpeg's runtime input dimension variables:

// ✓ Correct: caps at 1080p, passes through smaller sources untouched
-vf "scale='min(iw,1920)':'min(ih,1080)':force_original_aspect_ratio=decrease"

iw and ih are evaluated at runtime against each input file. A 720p source passes through unchanged; a 4K source scales down to 1080p. The single quotes around each min() expression are required — without them FFmpeg's filter parser treats the comma inside min() as a filter chain separator.

Source resolutionOutput with correct filter
1920×10801920×1080 (unchanged)
1280×7201280×720 (unchanged)
3840×2160 (4K)1920×1080 (downscaled)
1440×1080 (4:3 BD)1440×1080 (unchanged — both dims ≤ cap)
⚠ force_original_aspect_ratio=decrease

This flag ensures the output never exceeds your target dimensions while preserving the original aspect ratio. Without it, a 1440×1080 source would be stretched to 1920×1080. Always include it when you care about correct aspect ratio.


Audio — copy vs re-encode

The rule is simple: copy audio when the codec is container-compatible, re-encode when it isn't.

For MP4 output, AAC and MP3 copy cleanly. AC3 (Dolby Digital) and DTS technically work in MP4 but compatibility varies by player — copy is fine for Jellyfin and Apple TV, but may cause issues elsewhere. EAC3 and DTS-HD/MA require re-encode for MP4.

For MKV output, almost any codec copies without issue.

Source codec MP4 target MKV target
AACCopyCopy
MP3CopyCopy
AC3 / Dolby DigitalCopy (Jellyfin/AppleTV OK) or re-encode to AACCopy
DTSRe-encode to AAC recommendedCopy
EAC3 / TrueHD / DTS-MARe-encode to AACCopy
Opus / VorbisRe-encode to AACCopy
⚠ Never combine -c:a copy with -ac or -b:a

-c:a copy streams audio through untouched — FFmpeg cannot simultaneously copy and remix channels or change bitrate. Adding -ac 2 or -b:a 160k alongside copy will either error or silently be ignored depending on FFmpeg version. Only emit -ac and -b:a when re-encoding.

// Copy path (source is AAC)
-c:a copy
# Do NOT add -ac 2 or -b:a here
// Re-encode path (source is DTS/AC3)
-c:a aac -b:a 160k -ac 2

Color range

Most anime sources — BDRip, WEB-DL — use limited (TV) range, where luma values run from 16–235 rather than the full 0–255. FFmpeg's -color_range flag signals this to the decoder and downstream players.

FlagRangeUse when
-color_range tv Limited (16–235) Standard for anime BDRip and WEB-DL
-color_range pc Full (0–255) Screen recordings, scans, sources explicitly tagged full-range
⚠ Mismatch causes visible color shift

Signaling pc on a limited-range source will cause players to expand the range incorrectly, making the image look washed out with crushed blacks and blown highlights. When in doubt, use tv for BD/streaming sources.


The full recommended command

This is the command that comes out of applying everything above — NVENC HEVC, 10-bit, correct scale filter, audio copy with fallback logic, and sensible defaults for Jellyfin/Apple TV playback.

// Recommended — HEVC NVENC, main10, audio copy (AAC source)
ffmpeg -i {INPUT} \
  -map 0:v:0 -map 0:a:{AUDIO_TRACK} \
  -c:v hevc_nvenc \
  -cq 24 \
  -preset p6 \
  -profile:v main10 \
  -level 4.1 \
  -vf "scale='min(iw,1920)':'min(ih,1080)':force_original_aspect_ratio=decrease" \
  -color_range tv \
  -pix_fmt yuv420p10le \
  -g 120 \
  -c:a copy \
  -map_chapters 0 \
  -map_metadata 0 \
  -y {OUTPUT}
// Variant — audio re-encode (DTS / AC3 / incompatible source)
  # Replace -c:a copy with:
  -c:a aac -b:a 160k -ac 2
FlagValueWhy
-c:v hevc_nvencHEVC via NVENCGPU-accelerated, better compression than H.264
-cq 24Quality targetHigh quality, ~15–20% of BDRip source size
-preset p6NVENC quality presetBest compression/time ratio on laptop GPUs
-profile:v main1010-bit HEVCPreserves source bit depth, prevents banding
-pix_fmt yuv420p10le10-bit pixel formatRequired to match main10 profile
-level 4.1HEVC level1080p60 max; broad device support
scale='min(iw,1920)'...Smart scaleCaps at 1080p, never upscales, preserves AR
-color_range tvLimited rangeCorrect for BD/streaming anime sources
-g 120Keyframe intervalBetter compression than 60; fine for Jellyfin seeking
-c:a copyAudio passthroughZero quality loss when source is AAC-compatible
-map_chapters 0Keep chaptersPreserves OP/ED chapter markers from BD sources
-map_metadata 0Keep metadataPreserves title, language tags, etc.

CPU fallback (no NVIDIA)

If you're on AMD, Intel, or a system without a compatible NVIDIA GPU, replace the video encoder section with libx265 (software HEVC). CPU encoding is significantly slower but produces better compression efficiency per quality unit than NVENC.

// CPU encoding — libx265
  -c:v libx265 \
  -crf 20 \
    # libx265 uses -crf not -cq; 20 ≈ NVENC CQ 24 in output size
  -preset slow \
  -x265-params "profile=main10:pix_fmt=yuv420p10le"
ℹ Intel Arc / QSV

Intel Arc GPUs support HEVC via QSV (hevc_qsv). Quality control uses -global_quality instead of -cq. Intel's QSV HEVC quality is competitive with NVENC at equivalent speeds. Replace hevc_nvenc with hevc_qsv and -cq with -global_quality if targeting Arc hardware.

Personal Research — Opinionated Guide

This guide reflects personal research, testing, and preferences accumulated through encoding a large personal anime library. The settings and recommendations here are not official FFmpeg documentation, and they may not be optimal for every use case, source type, or hardware configuration.

FFmpeg encoding involves many variables — source quality, GPU generation, target device, personal quality thresholds — and reasonable people arrive at different conclusions. Test your own sources and adjust accordingly. A few single-episode test encodes at different CQ values before processing an entire series will always tell you more than any guide can.

For authoritative reference, see the official FFmpeg documentation and the H.265 encoding guide on the FFmpeg wiki.