Last update : September 17, 2013
I wanted to know the best X264 parameters to encode my personal movies with ffmpeg for my family website. I rendered 375 frames (15 seconds) from the open-source Big-Buck-Bunny image files (360-png) with different settings, starting at frame 1.113. This post refers to my former post about AVC (H264) video settings.
The common parameters for the encoding are :
- -vcodec libx264
- -f image2
- -pix_fmt yuv420p (chroma subsampling : 4:2:0)
- -tune animation
- resolution (pal) : 640 x 360 pixels
- frame rate : 25 fps
1st Test
The ffmpeg settings for the first test series are :
- -preset veryslow
- -profile:v baseline
- -level 3
- -refs 1
The value of the Constant Rate Factor (CRF) was changed from 20 to 32, in steps of 3. Here are the results :
| CRF | Filesize (KB) | Videostream (Kbps) | Bits/(Pixel*Frame) |
| 20 | 2.430 | 1.326 | 0.230 |
| 23 | 1.472 | 802 | 0.139 |
| 26 | 877 | 478 | 0.083 |
| 29 | 531 | 289 | 0.050 |
| 32 | 338 | 183 | 0.032 |

Visually the quality difference between the movies with an CRF = 20 and CRF = 32 is not perceptible. These are snapshots of the two movies :
![]() CRF = 20 Image size = 39,6 KB |
![]() CRF = 32 Image size = 32,6 KB |
2nd Test
The ffmpeg settings for the second test series are :
- -crf : 20
- -profile:v baseline
- -level 3
- -refs 1
The three presets veryslow, medium and ultrafast have been used. Here are the results :
| Preset | Filesize (KB) | Videostream (Kbps) | Bits/(Pixel*Frame) |
| veryslow | 2.430 | 1.326 | 0.230 |
| medium | 2.729 | 1.489 | 0.258 |
| ultrafast | 5.276 | 2.880 | 0.500 |

Presets are designed to reduce the work needed to generate sane, efficient commandlines to trade off compression efficiency against encoding speed. The default preset is medium. If you specify a preset, the changes it makes will be applied before all other parameters are applied.
The X264 settings of the different presets are :
ultrafast
- –no-8x8dct
- –aq-mode 0
- –b-adapt 0
- –bframes 0
- –no-cabac
- –no-deblock
- –no-mbtree
- –me dia
- –no-mixed-refs
- –partitions none
- –rc-lookahead 0
- –ref 1
- –scenecut 0
- –subme 0
- –trellis 0
- –no-weightb
- –weightp 0
veryslow
- –b-adapt 2
- –bframes 8
- –direct auto
- –me umh
- –merange 24
- –partitions all
- –ref 16
- –subme 10
- –trellis 2
- –rc-lookahead 60
3rd Test
The ffmpeg settings for the third test series are :
- -preset veryslow
- -crf : 20
- -profile:v baseline
- -level 3
The numer of reference frames was changed to the values 1, 2, 4, 8 and 16. Here are the results :
| Ref frames | Filesize (KB) | Videostream (Kbps) | Bits/(Pixel*Frame) |
| 1 | 2.430 | 1.326 | 0.230 |
| 2 | 2.378 | 1.297 | 0.225 |
| 4 | 2.203 | 1.201 | 0.209 |
| 8 | 2.079 | 1.134 | 0.197 |
| 16 | 2.027 | 1.106 | 0.192 |

4th Test
The ffmpeg settings for the fourth test series are :
- -crf : 20
- -profile:v main
- -level 3
The numer of reference frames was changed to the values 4, 8 and 16 for the two presets veryslow and medium (4 is the minimum number of reference frames of the main profile). Here are the results :
| Preset | Ref frames | Filesize (KB) | Videostream (Kbps) | Bits/(Pixel*Frame) |
| veryslow | 4 | 1.517 | 826 | 0.143 |
| veryslow | 8 | 1.411 | 768 | 0.133 |
| veryslow | 16 | 1.389 | 756 | 0.131 |
| medium | 4 | 1.700 | 926 | 0.161 |
| medium | 8 | 1.636 | 891 | 0.155 |
| medium | 16 | 1.607 | 875 | 0.152 |

5th Test
The ffmpeg settings for the fifth test series are :
- -preset veryslow
- -crf : 20
The profiles and levels have been changed. Here are the results :
| Profile@Level | Filesize (KB) | Videostream (Kbps) | Bits/(Pixel*Frame) |
| baseline@3.0 | 2.430 | 1.326 | 0.230 |
| main@3.0 | 1.517 | 826 | 0.143 |
| high@3.0 | 1.405 | 765 | 0.133 |

Profiles are not set by default in X264. If a profile is specified, it overrides all other settings, so that a compatible stream will be guaranteed.
The X264 settings of the different profiles are :
baseline
- –no-8x8dct
- –bframes 0
- –no-cabac
- –cqm flat
- –weightp 0
- No interlaced
- No lossless
main
- –no-8x8dct
- –cqm flat
- No lossless
high
- No lossless
A level inside a profile specifies the maximum picture resolution, frame rate and bit rate that a decoder may use.
The complete detailed informations about settings are available in the x264.exe inbuild documentation, accessible with the command x264 –fullhelp .
The following list provides some links to websites with more informations about ffmpeg and x264 video encoding :
- X264 Settings, MeWiki
- X264 Encoding Suggestions, MeWiki
- H.264/MPEG-4 AVC, Wikipedia
- FFMpeg Benchmark – Effect of Threads and Bitrate on Image Quality, by GentooVPS.net














The windows key PrtScnSysRq captures the entire screen and copies it to the clipboard. You find this key at the upper right of your keyboard. Holding down the Alt key when pressing the PrtScnSysRq key, Windows captures only the currently active window and copies it to the clipboard. In Windows 10, use the Windows Log key together with the PrtScnSysRq key to capture the whole screen which is saved into a Screenshots Folder inside the Pictures directory.










