AyumiLove Megui x264 Encoding Settings Guide (HD Quality)

Here are my new encoding settings for HD (High Definition) anime videos! Use this settings for your favorite videos that you re-watch often since its worth the extra bytes. I did multiple experiments here and this results in clearer and sharper images for fast motion scenes.

Ayumilove Experimental Notes on Fast Motion Scenes

CRF: I set this to CRF23 to gain extra bytes for sharper lines compared to CRF25. As this will considerably increases the video file size by 2 folds of CRF28, I recommend using Ordered Chapter to separate the opening and closing parts of anime video. For videos that you seldom watch but want to save it for memory, you can try SD Quality Megui Video Encoding settings which saves 20% (slow motion scenes) to 50% (fast motion scenes) file size compared to this HD Qaulity.

Deblock: I set the Deblock to 0 since extra +/- seems to have detrimental impact on faster scenes where the lines are blurred to fade into surrounding colors or jagged alot.

B-Frames / R-Frames: Increasing this higher to values like 8 would slowdown the encoding process considerably with little gain unless you have time to spare or have high end CPU.

AQ-Strength: Set this to 1. Don’t set below 1 (e.g. aq=2:0.6.00) as this will make the images smeared with dead colors on flat colored images. Setting it too high (e.g. aq=2:2.00) may cause artifacts like whitespots on flat colored images. High AQ-Strength increases video file size! It uses more bitrate to preserve grains without removing them. If using high CRF such as CRF=28 with High AQ, fast motion scene will look terrible as CRF=28 has a cap/limit of how much bitrate that AQ can use.

PSYRD: Set psy_rd=0 as psy_rd=1 (e.g psy_rd=1.00:0.00) makes the animation lines jagged or make the line bolder which doesn’t look great compared to the original source file. Also, setting psy_rd to zero reduces the bitrate (smaller file size being encoded).

ME.Range: I found out that ME.Range=16 makes the animation lines a little faded out in some parts, where as ME.Range=32 has the lines sharp as the original file but you won’t notice this on a non-fast motion scene. High ME.Range settings do take up extra encoding time but worth it if you watch the anime on big screen, 50′ inch monitor, you won’t notice this faded line easily. The ME Algorithm used with the high ME Range is Multi Hex (me=umh).

Quantizers Compression (qcomp): Set this to 1.0 (HD Quality). This is the most important aspect that sets the encoded video file close to 95~99% similarly to the source file. This settings makes it as sharp as CRF=18 with the default settings of qcomp=0.60 without bloating up the video file size unnecessarily for fast and slow motion scenes. My goal is to have small MiniMKV video file size while still retaining most of the quality on fast motion scenes.

Audio VBR Q=0.4 AAC-LC: I set this to 0.4 instead of 0.35 since the extra bits might be worth when you are listening on a mainstream or high end audio speakers. Also, if your source videos comes in FLAC audio type, don’t convert it! Just mux it into the video. Even though FLAC file size is huge, its audio is compressed losslessly and when you listen on a high-end pc speakers or headphones, you can hear the differences. However, if you want to fit in the range of MiniMKV, then you can encode the audio. [Oct 21, 2012 Notes] Try encoding the audio file and compare the encoded audio file size with the original. If the encoded file size is larger than the original audio file size, scrap the encoded and use the original because its not worth keeping a large audio file that might lost some audio quality along the way.


Below are my new current settings updated on 12-September-2012


Encoding Mode : Constant Quality (CRF)
Bitrate : CRF23 (10bit/Hi10p) or CRF21 (8bit)
Preset : Medium
Tuning : Animation
AVC Profile : High Profile
AVC Level : 5.1
Target Playback Device : Default
Show Advanced Settings : Checked


H.264 Features
Deblocking : Checked
Deblocking Strength : 0
Deblocking Threshold : 0
CABAC : Checked
GOP Size
GOP Calculation : FPS
Maximum GOP Size : 250
Minimum GOP Size : 25
Open GOP : Uncheck
Nb of Slices by Frame : 0
Max size (in bytes) : 0
Max size (in mbs) : 0
B Frames
Weighted Predition for B Frame : Checked
Number of B-Frames : 5
B-Frame Bias : 0
Adaptive B-Frames : 2-Optimal
B-Pyramid : Normal
Number of Referenced Frames : 5
Number of Extra I-Frames : 40
P-frame Weighted Prediction : Smart
Interlaced Mode : none
Pulldown : none
Adaptive I-Frame Decision : Checked

Min/Max/Delta : 10/69/4
Quantizers Ratio(I:P/P:B) : 1.4 / 1.3
Chroma QP Offset : 0
Credits Quantizer : 40
Rate Control
VBV Buffer Size : 0
VBV Maximum Bitrate : 0
VBV Initial Size : 0.9
Bitrate Variance : 1.0
Quantizers Compression : 1.0 (HD Quality)
Temp. Blur of est. Frame Complexity : 20
Temp. Blur of Quant after CC : 0.5
Adaptive Quantizers
Mode : Auto-Variance AQ (Experimental) 2
Strength : 1.00
Quantizers Matrices : Flat (none)
Nb of Frames for Lookahead : 40
Use Mb-Tree : Checked


Motion Estimation
Chroma M.E : Checked
M.E Range : 32 (me_range=32)
M.E Algorithm : Multi Hex (me=umh)
Subpixel Refinement : 10 – QP-RD (subme=10)
MV Prediction Mod : Auto
Trellis : 2 – Always
Psy-RD Strength : 0.00
Psy-Trellis Strength : 0.00
No Mixed Referenced Frames : Checked
No Dct Decimation : Unchecked
No Fast P-Skip : Checked
No Psychovisual Enhancements : Unchecked
Noise Reduction : 0
Partitions : AdaptiveDCT + I4x4 + I8x8 + P8x8 + B8x8 (Unchecked P4x4)
Blu-Ray : None
Use Access Unit Delimiters : Unchecked
Fake Interlaced : Unchecked
Enable Blu-Ray Compatibility : Unchecked


Threads (0=Auto) : 0
Thread-Input : Checked
Non Deterministic : Unchecked
Slow First Pass : Unchecked


Preferred Decoder : NicAudio
Output Channels : Keep Original Channels
Sample Rate : Keep Original
Apply Dynamic Range Compression : Unchecked
Normalize Peaks to 100% : Unchecked
Nero Digital Options : VBR Q=0.40 (equivalent to ABR 128 Kbps)
AAC Profile : Automatic (HE-AAC for 128 kbits and below or AAC-LC for 128 kbits and above)

Leave a Reply

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

14 thoughts on “AyumiLove Megui x264 Encoding Settings Guide (HD Quality)

  1. Ayumilove Post author

    @Dr Potatoe: It’s been several years I created this guide, I do not remember much on the ffmpeg command.

  2. Dr Potatoe

    what’s the ffmpeg command for this, please can you tell me

  3. Aliqandil

    This would be the command line:

    program –preset veryslow –tune animation –bframes 5 –ref 5 –qpmin 10 –ratetol 1.0 –qcomp 1.0 –rc-lookahead 40 –aq-mode 2 –aq-strength 1.0 –merange 32 –partitions p8x8,b8x8,i8x8i4x4 –psy-rd 0:0 –no-mixed-refs –no-fast-pskip –nal-hrd vbr –output “output” “input”

  4. Ayumilove

    @mark: Yeah it works too, just that the smaller the video resolution, you will need to increase the quality else it will pixelate whereas the higher video resolution would be the opposite.

  5. mark

    love the tutorial, just wondering if this would work for re-encoding 1280×720 to a smaller file.

  6. ColdFlaMes

    yeah i did and the green frames exist at the beginning… i fixed it though by using FFMpegSource2 instead of AVISource… not sure why this happens as i’ve encoded the same file in the past and the green frames do not appear (decided to re-enode the videos again from the original source since my old encodes were set at a really low kbps xD)

  7. Ayumilove

    Hi ColdFlaMes, have you tried outputting the video? Does the rendered video has those green frames similarly to the avisynth preview?

  8. ColdFlaMes

    hello! awesome tutorial.
    one thing though, why are there green frames at the beginning of the video after encoding or even when i preview the avisynth script in VirtualDub. Any solution to this? (the green frames are not found on the original video, it only appears after making the avisynth script)

  9. Ayumilove

    Hi Norvin Tambunan, I have not tried it yet. Perhaps you can share your experiments with me about the QPmin 🙂

  10. Norvin Tambunan

    hey, i wonder if there’s a big difference with QPmin = 0 and QPmin = 10 :/

  11. dwi

    can you make it into Megui profiles and share to us?
    thank you

  12. dwi

    can you make it into Megui profiles and share to us?

  13. Ayumilove

    Hi Billy, From x264 wiki page it says Open-GOP is an encoding technique which increases efficiency. Some decoders don’t fully support open-GOP streams, which is why it hasn’t been enabled by default. You should test with all decoders your streams will be played on, or (if that’s impossible) wait until support is generally available.

    I’m not sure what it does yet, perhaps speed up encoding or makes video quality better, need to test it out.

    Found out something interesting here: The best way I remember the Closed/Open GOP issue is this:
    Closed GOPs make playing a DVD in Fast Rewind easier.

    Open GOPs mean that it the last B-frame has to look at both previous and upcoming frames to create the full image for display on screen. (small frame size, since it borrows from other frames)

    Closed GOPs only need to look at previous frames, making each GOP (Group of Pictures) self-contained (and with no borrowing from external frames, the frame size goes up). No need to look anywhere but at one GOP to render any frame in the group.

    The reason Closed GOPs are needed for Editing and Multi-angle videos. For editing, the closed GOPS make it easier to conduct frame-accurate edits, since there is no worry of lost data if the previous or following GOP fets cut off. For Multi-angle, you have a main storyline, with selected “chapters” where the alternate video starts playing. If the GOPs were open, and you hit a “chapter-branch,” the player would have to load the GOP at the end of the chapter, the following normal GOP and the alternate following GOP to get a fully-rendered B-frame (regardless of which “storyline you were watching). Having a Closed GOP guarantees that no matter where you are in the storyline, each pack of frames is self-contained and can play without extra overhead being loaded. So, again, in a nutshell; For the average video Open GOPs are the way to go, unless you have a DVD player that doesn’t like playing in fast-rewind. Other than that, there is NO reason to use Closed GOPs if you can avoid it.

  14. billy

    Why no open-gop? It would break less compatibility than 10bit anyway.