The CRF Parameter: Quality Control
CRF (Constant Rate Factor) controls quality/size balance:
| CRF | Quality | Use |
|---|---|---|
| 18-20 | Visually lossless | High-quality archive |
| 23 | Standard (default) | General use |
| 28 | Acceptable | Light web/streaming |
| 35-40 | Low | Quick previews |
Basic H.264 Compression
# Standard (CRF 23)
ffmpeg -i original.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy compressed.mp4
# High quality (CRF 18)
ffmpeg -i original.mp4 -c:v libx264 -crf 18 -preset slow -c:a copy hq.mp4
# Re-encode audio
ffmpeg -i original.mkv -c:v libx264 -crf 23 -preset medium \
-c:a aac -b:a 128k compressed.mp4
Presets (speed vs compression)
ultrafast → fast → medium → slow → veryslow
- medium: recommended balance.
- slow/veryslow: better compression, slower.
H.265/HEVC (50% More Efficient)
ffmpeg -i original.mp4 -c:v libx265 -crf 28 -preset medium \
-c:a aac -b:a 128k -tag:v hvc1 compressed_h265.mp4
2-Pass Encoding (Exact File Size)
# First pass (analysis)
ffmpeg -i original.mp4 -c:v libx264 -b:v 6500k -pass 1 -an -f null /dev/null
# Second pass (final encode)
ffmpeg -i original.mp4 -c:v libx264 -b:v 6500k -pass 2 \
-c:a aac -b:a 128k compressed_2pass.mp4
Downscale Resolution
# 4K to 1080p
ffmpeg -i 4k.mp4 -vf "scale=1920:1080:flags=lanczos" \
-c:v libx264 -crf 20 -preset slow -c:a aac -b:a 192k 1080p.mp4
# To 720p
ffmpeg -i original.mp4 -vf "scale=1280:720:flags=lanczos" \
-c:v libx264 -crf 22 -preset medium -c:a aac -b:a 128k 720p.mp4
# Maintain aspect ratio
ffmpeg -i original.mp4 -vf "scale=1280:-2:flags=lanczos" \
-c:v libx264 -crf 22 1280px.mp4
GPU Acceleration (NVIDIA NVENC)
ffmpeg -i original.mp4 -c:v h264_nvenc -cq 23 -preset p4 \
-c:a aac -b:a 128k compressed_gpu.mp4
ffmpeg -i original.mp4 -c:v hevc_nvenc -cq 28 -preset p4 \
-c:a aac -b:a 128k h265_gpu.mp4
Batch Processing
for f in *.mp4; do
out="compressed_${f}"
ffmpeg -i "$f" -c:v libx264 -crf 23 -preset medium \
-c:a aac -b:a 128k "$out"
done
Codec Comparison
| Codec | Efficiency | Compatibility |
|---|---|---|
| H.264 | Baseline | ✅ Universal |
| H.265 | ~50% better | High |
| VP9 | ~40% better | High (browsers) |
| AV1 | ~60% better | Growing |
Conclusion
No visible quality loss: H.264 CRF 23 (universal standard). Halve the file size: H.265 CRF 28. Exact target size: 2-pass encoding. Maximum speed: GPU acceleration (NVENC/QSV/VideoToolbox).
Advanced Use Cases
Multi-platform distribution: each social network has preferred specs — YouTube accepts MP4 H.264 up to 4K 60fps with AAC 384 kbps; Instagram Reels prefers MP4 H.264 at 1080×1920 vertical; TikTok recommends MP4 H.264/H.265 up to 60 seconds with bitrate of 5-10 Mbps; LinkedIn caps at 5 GB and prefers MP4 H.264. Converting your master to each platform's exact specs before upload guarantees that the server's internal re-encoding (which always happens) starts from optimal input, preserving maximum final quality. Professional editing: editors like DaVinci Resolve, Premiere Pro and Final Cut Pro work best with intermediate codecs (ProRes, DNxHD, CineForm) rather than H.264 final-delivery — converting your material to an intermediate format before editing dramatically accelerates render and avoids generation loss in multi-track timelines. Live streaming: OBS Studio and Streamlabs require input in H.264/H.265 with keyframes every 2 seconds for HLS; converting recordings to this preset facilitates uplink.
Best Practices and Professional Tips
Two-pass encoding vs CRF: for specific target file size (e.g. "max 25 MB for WhatsApp") use two-pass; for target quality use CRF (Constant Rate Factor) with values 18-23 for H.264, 22-28 for H.265 — visually-lossless under normal conditions. Audio passthrough: if your destination video supports the original audio codec, use stream copy (-c:a copy in FFmpeg) — preserves 100% audio quality without re-encoding. Container vs codec: distinguish between container (MP4, MKV, MOV) and internal codec (H.264, H.265, AV1). Changing only the container is a trivial operation without re-encoding (seconds vs minutes for re-encode). HDR preservation: if your source is HDR10/Dolby Vision, ensure the destination also supports HDR — converting HDR to SDR permanently loses dynamic range. Frame rate: never increase frame rate (24→60 doesn't add real information); reducing it (60→30) removes frames without visible loss for most content.
Compatibility and Technical Considerations
KaijuConverter processes video with FFmpeg 6.x compiled with all critical extensions: x264/x265 for H.264/H.265 encoding with configurable presets (ultrafast to veryslow, default medium for balance), libvpx-vp9 for WebM, SVT-AV1 for modern AV1 encoding with 10-bit color space support, libfdk-aac for AAC audio, libopus for Opus. We support files up to 500 MB and resolutions up to 4K (3840×2160) at 60 fps. The cloud pipeline uses hardware acceleration when available (NVENC/QuickSync) which accelerates 5-10× over CPU encoding. Processing time: a 1080p 60-second video typically converts in 12-30 seconds depending on destination codec and preset. 4K HDR material may require 2-5 minutes. Limitations: DRM-protected files (Netflix, Disney+, Amazon Prime, Apple TV+) cannot be converted — DRM blocks stream extraction. Very specific proprietary codecs (RED RAW, ARRI Alexa raw, Sony X-OCN) require dedicated software. Privacy: video encrypted in transit (TLS 1.3), processed in isolated Docker containers, automatically deleted after 2 hours with secure multi-pass overwrite.
Related conversions
Common video conversions that pair well with this guide: