I have video file with 40000k bitrate, so it is around 30GB and I want to transcode into hevc (or maybe av1) with lower bitrate. Well, with ffmpeg libx265 28 I get down to 5000k, but it was not very gentle to details. For example, in scene with people running on grass track from some distance, with original quality I can see both grass and runners, but in "compressed" version it looks messy, to the point where "grass" is more like "green gradients with compression artifacts", and runners are no better. What's the proble and what can be done?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Okay, let's break down why your 5000kbps HEVC transcode lost significant detail, and what you can do to get better quality at a lower bitrate.
Why the Detail Loss?
Massive Bitrate Reduction: Going from 40000k to 5000k is an 87.5% reduction in bitrate. While HEVC is much more efficient than older codecs, reducing the data by that much is very aggressive, especially for detailed and complex scenes.
Content Complexity: Scenes with high spatial detail (grass, leaves, textures) and/or fast motion (runners moving quickly) require significantly more bits to represent accurately than simple scenes (like a talking head against a plain background). At 5000kbps, the encoder simply didn't have enough bits to allocate to those complex areas, leading to simplification, blocking, and artifacting.
Encoding Settings: The default or common ffmpeg settings for libx265 (especially the preset and rate control method) might not be optimized for preserving fine detail at such a low bitrate.
What Can Be Done?
Here are the main strategies, often used in combination:
Increase the Target Bitrate or Use Constant Rate Factor (CRF):
Bitrate is too Low: 5000k might just be insufficient for the content complexity you have. You might need to aim for 8000k, 10000k, or even 15000k to retain satisfactory detail for those challenging scenes. This will increase the file size, but it's a direct trade-off.
Use CRF: Instead of specifying an average bitrate (-b:v 5000k), use Constant Rate Factor (-crf). CRF tells the encoder to target a specific quality level rather than a specific file size/bitrate. The bitrate will then fluctuate, using more bits for complex scenes (like your grass/runners) and fewer for simple scenes. This usually results in more consistent visual quality throughout the video.
For libx265, a good starting point for CRF is 24 to 20. Lower values mean higher quality (and higher bitrate). 23 is often considered roughly equivalent to x264's 23. Start with -crf 22 or -crf 20 and see how the quality (and resulting file size/bitrate) looks. This is often the most effective way to improve quality at a given perceived level.
Use a Slower Encoding Preset:
The preset option controls the trade-off between encoding speed and compression efficiency/quality. Faster presets (like medium, slow) spend less time analyzing the video, while slower presets (slower, veryslow, placebo) spend much more time finding the best ways to compress the data.
Using a slower preset gives the encoder more opportunity to make better decisions about how to allocate bits and which compression tools to use, which is crucial for preserving detail in difficult areas.
Try using -preset slower or -preset veryslow. Be aware that encoding time will increase significantly (potentially many times longer).
Consider AV1 (SVT-AV1):
AV1 is generally considered more efficient than HEVC, meaning it can potentially achieve similar quality at a lower bitrate.
The SVT-AV1 encoder (libsvtav1) in ffmpeg is usually the best choice for speed and quality balance compared to libaom-av1.
AV1 encoding is generally slower than HEVC encoding at comparable quality levels.
AV1 compatibility is still lower than HEVC, though improving (supported by modern browsers like Chrome/Firefox, YouTube, some hardware players).
Like HEVC, use CRF with SVT-AV1. The CRF scale is different; a range like 28 to 20 is a rough starting point, with lower values being higher quality.
Advanced Encoder Tuning (x265):
libx265 has many advanced options.
--tune detail or --tune film: These options can sometimes help preserve fine details or film grain, respectively. --tune detail might be relevant for your grass issue.
--aq-mode 3: Adaptive Quantization mode 3 is often recommended for better visual quality, distributing bits more intelligently.
These require more experimentation and understanding of x265 options.
Filter the Input (Use with extreme caution):
Sometimes, noise or film grain in the original source can consume a lot of bits during compression, leaving fewer for actual details. A very light denoise before encoding might sometimes help, but it can also soften legitimate details. For a 40Mbps source, this is less likely to be the primary issue unless the source itself has problems. Avoid filtering unless you are very careful.
Recommended Approach: Iterate with CRF and Slower Presets
The most impactful changes you can make are usually:
Switching from ABR (-b:v) to CRF (-crf).
Using a slower preset.
Example FFmpeg Commands:
Let's assume your input file is input.mkv.
Option 1: HEVC (libx265) with CRF and Slower Preset
-crf 22: Target a quality level. 22 is a good balance, try 20 for higher quality (larger file), 24 for smaller file (lower quality). Experiment with this value.
-preset slower: Use a slower preset for better compression efficiency. Try veryslow if slower isn't enough and you have the time.
-c:a copy: Copy the audio streams without re-encoding. This saves time and avoids generational loss for audio.
output_hevc_crf22_slower.mkv: Your output file name.
Option 2: HEVC (libx265) with CRF, Slower Preset, and Detail Tuning
-x265-params "tune=detail:aq-mode=3": Pass specific options to the x265 encoder. tune=detail might help with your specific grass issue. aq-mode=3 is generally recommended.
Option 3: AV1 (libsvtav1) with CRF and Slower Preset
-crf 26: AV1 CRF scale is different. 26 is a starting point; try lower (e.g., 24, 22) for higher quality, higher (e.g., 28, 30) for smaller size. Experiment.
-preset 6: SVT-AV1 presets are numbered 0-8 or 0-12 (faster is lower number). Preset 6 is a reasonable balance. Try 5 or 4 for higher quality (much slower), 7 or 8 for faster encoding (lower quality). Experiment.
-c:a copy: Copy audio.
How to Experiment:
Use Short Clips: Don't encode the whole 30GB file each time you test settings! Use ffmpeg to cut a short clip (e.g., 30 seconds to 1 minute) that contains one of the problematic scenes (like the grass/runners).
Then, use short_clip.mkv as your input for testing different -crf and -preset values.
Compare Results: Watch the transcoded clips side-by-side with the original in a good video player. Pay attention to the details you care about (grass, textures, motion). Compare file sizes/bitrates achieved by different CRF values.
Balance: Find the best balance between quality, file size, and encoding time that you are willing to accept. You might find that 5000kbps is simply too low for the quality you want and need to go higher.
Summary:
Your main issue is likely the combination of a very aggressive bitrate reduction and settings that weren't optimized for quality at that low bitrate.
Prioritize using CRF over ABR (-b:v). This lets the encoder decide where to use bits based on scene complexity.
Use a slower -preset. This gives the encoder more time to find better compression.
Experiment! Start with CRF + slower preset and encode short clips to see the quality/size trade-off. You may find you simply need a higher bitrate than 5000k for the desired quality level.
Consider SVT-AV1 as an alternative if compatibility is less of a concern, but expect longer encoding times.