You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用FFmpeg复现低码率高画质的H.264视频编码参数?

Alright, let's break this down step by step to replicate that efficient, high-quality encoding and handle the yuvj420p format you're asking about.

Replicating the High-Quality, Low-Bitrate Encoding

First, we’ll lean on your ffprobe and mediainfo outputs to reverse-engineer the source video’s encoding strategy—those details are critical for matching its efficiency. Here’s how to translate that into actionable FFmpeg parameters:

Step 1: Extract Key Source Encoding Details

Start by pulling these core specs from your source video to align your encoding foundation:

  • Codec: Run ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 to confirm if it’s H.265/HEVC, AV1, or an optimized H.264 profile. Low bitrate + high quality is almost always HEVC or AV1 (they outperform H.264 by 30-50% in compression efficiency).
  • Profile/Level: Check ffprobe -v error -select_streams v:0 -show_entries stream=profile,level -of default=noprint_wrappers=1—higher profiles (like Main10 for HEVC) unlock better compression tools.
  • Bitrate Control: Look for CRF (constant rate factor) vs. CBR/VBR in mediainfo. CRF is far more likely for consistent, high-quality low-bitrate output, so you’ll want to mirror that instead of locking to a fixed bitrate.
  • Advanced Tools: Scan ffprobe’s stream details for reference frame counts, B-frame quantities, adaptive quantization modes, and motion search ranges—these are the "secret sauce" behind efficient compression.

Step 2: Tailored FFmpeg Parameter Sets

Based on common high-efficiency encoding setups, here are the parameters to match your source’s quality:

If the Source is H.265/HEVC (Most Probable)

This codec is the top candidate for your 4324 kb/s high-quality result. Use libx265 with these settings:

ffmpeg -i input.mp4 -c:v libx265 -b:v 4500k -preset slow -crf 22 -x265-params "rc-lookahead=60:bframes=16:aq-mode=3:merange=57:colorprim=bt709:transfer=bt709:colormatrix=bt709" output.mp4
  • -preset slow: Balances compression efficiency and speed (your source almost certainly used a slow preset to squeeze maximum quality at low bitrate)
  • -crf 22: Adjust this to tune quality—lower values = better quality (start at 22, tweak ±2 until you match the source)
  • -x265-params: Enables advanced compression tools:
    • rc-lookahead=60: Lets the encoder plan bitrate allocation over more frames for smoother quality
    • bframes=16: Uses more bidirectional frames to compress static content better
    • aq-mode=3: Adaptive quantization preserves detail in high-complexity areas (like text or textures)
    • merange=57: Larger motion search range finds better frame matches for tighter compression

If the Source is AV1

AV1 is even more efficient than HEVC. Use libsvtav1 (faster than libaom-av1) for this:

ffmpeg -i input.mp4 -c:v libsvtav1 -preset 6 -crf 23 -g 240 -b:v 4300k output.mp4
  • -preset 6: Middle ground between speed and compression (lower numbers = slower, better compression)
  • -crf 23: Similar to HEVC’s CRF—adjust to match source quality
  • -g 240: Sets a keyframe every 10 seconds (matches typical streaming setups; adjust if your source uses a different interval)

If the Source is Optimized H.264

Less likely, but possible if it’s using a high-profile H.264 build:

ffmpeg -i input.mp4 -c:v libx264 -preset slow -crf 20 -x264-params "bframes=8:aq-mode=2:merange=32:profile=high" output.mp4
Generating yuvj420p Format

yuvj420p is the JPEG-style full-range (PC-level) YUV 4:2:0 pixel format. Here’s how to work with it in FFmpeg:

Raw YUV File Output

For an uncompressed raw yuvj420p file:

ffmpeg -i input.mp4 -pix_fmt yuvj420p output.yuv

Note: Raw YUV files are extremely large—ensure you have enough storage space.

Encoded Video with yuvj420p Pixel Format

If you want to encode a video using yuvj420p (e.g., for compatibility with older tools expecting JPEG-style YUV):

ffmpeg -i input.mp4 -c:v libx264 -pix_fmt yuvj420p -color_range pc -colorspace bt709 -color_trc bt709 -color_primaries bt709 output.mp4
  • -color_range pc: Explicitly sets full pixel range (matches yuvj420p’s definition)
  • The colorspace, color_trc, and color_primaries flags ensure correct standard HD color mapping.

Converting from Limited-Range to yuvj420p

If your input uses TV-range (limited) YUV, convert it to full-range yuvj420p with:

ffmpeg -i input.mp4 -vf "format=yuvj420p,colorspace=bt709:trc=bt709:primaries=bt709" -color_range pc output.yuv

内容的提问来源于stack exchange,提问作者AdmiralJonB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:08:30