Log in

View Full Version : x264 settings for PC games?


orion44
25th April 2011, 12:04
Hello...

I am about to encode Call of Duty 1 PC game, that was recorded by fraps,
but I am unsure about which x264 settings should I use.

Would the default settings be optimal, or is there any additional option that I should set?

Which x264 settings would you recommend?

LoRd_MuldeR
25th April 2011, 12:34
I think this kind of "first person" shooters will probably benefit from --tune film. And of course --preset <slowest preset you can afford> won't hurt either ;)

Moreover I would go with CRF mode and choose the highest possible CRF value that still satisfies your eyes (e.g. start with something like CRF=16 and increase successively).

orion44
25th April 2011, 17:35
Thanks.

hopstiii
25th April 2011, 18:34
If u wanna send the video to YouTube,
then u need to encode another version for it.
1) From x264vfw GUI u need to enable
* fast decode
* zero latency

Otherways YT can't decode the video. That means
No cabac, no b-frames

And maybe also
weightp=0
rc=cqp
mbtree=0

Snowknight26
26th April 2011, 01:18
Not true. YouTube works just fine with 'normal' settings, such as:
x264.x64 --crf 19 --preset veryslow --deblock -2:-2 --ref 7 --aq-strength 0.5 --psy-rd 0.5:0.1 --fullrange on --output "%%~nA.noaudio.mkv" "%%A"

orion44
26th April 2011, 02:27
1. Does fraps output PC range or TV range videos?

2. Does fraps decoder decode in PC or TV range?

3. Is the following script correct:

#LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ColorMatrix\ColorMatrix.dll")
DirectShowSource("D:\Temp\Level_2.avi", audio=false, pixel_type="RGB32")
ConvertToYV12()
#ColorMatrix(clamp=0)
Trim(7193,8632)
#LanczosResize(512,384,taps=3)
Spline36Resize(512,384)

4. Should I maybe set ConvertToYV12(matrix="PC.601")?

5. For youtube uploads, do I set TV or PC Range?

6. With the above script, the x264 output looks brighter than the original fraps video (In Pot Player, it looks the same as original, in BS Player it looks brighter).
Is this because of the different player video settings?

7. What is the correct way to encode fraps videos with x264, for uploading to youtube?

hopstiii
26th April 2011, 05:39
Not true. YouTube works just fine with 'normal' settings, such as:

What is wrong in this settings then, youtube decoded yesterday only some intra frames from avi mp4 mkv video with settings:

Format : AVI
Format/Info : Audio Video Interleave
File size : 137 MiB
Duration : 4mn 53s
Overall bit rate : 3 915 Kbps
Writing application : Lavf52.102.0
Writing library : VirtualDub build 32842/release

Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Codec ID : H264
Duration : 4mn 53s
Bit rate : 2 500 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.090
Stream size : 87.0 MiB (64%)
Writing library : x264 core 114 r1913bm 5fd3dce
Encoding settings : cabac=1 / ref=8 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 /
psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 /
fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 /
bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 /
keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=2500 / ratetol=1.0 /
qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00


And there was no video (solid gray) at all but only sound with this settings:

Format : Matroska
File size : 120 MiB
Duration : 4mn 53s
Overall bit rate : 3 435 Kbps
Movie name : Best Movies Ever Known To Humankind 720p
Encoded date : UTC 2011-04-23 05:26:28
Writing application : mkvmerge v4.4.0 ('Die Wiederkehr') built on Oct 31 2010 21:52:48
Writing library : libebml v1.0.0 + libmatroska v1.0.0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 8 frames
Muxing mode : Header stripping
Codec ID : V_MPEG4/ISO/AVC
Duration : 4mn 53s
Nominal bit rate : 2 500 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.090
Writing library : x264 core 114 r1924 08d04a4
Encoding settings : cabac=1 / ref=9 / deblock=1:0:0 / analyse=0x3:0x133 / me=tesa / subme=10 / psy=1 /
psy_rd=1.00:0.00 / mixed_ref=1 / me_range=40 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 /
fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 /
bframes=16 / b_pyramid=1 / b_adapt=2 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=300 /
keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=2500 / ratetol=1.0 /
qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=50000 / vbv_bufsize=50000 /
nal_hrd=none / ip_ratio=1.40 / aq=1:1.00


I tested RipBot264 encoder and VirtualDub x264vfw encoder with different fourcc's
After reuploading 2 days same file, this was only one that worked:

Format : AVI
Format/Info : Audio Video Interleave
File size : 315 MiB
Duration : 4mn 53s
Overall bit rate : 9 023 Kbps
Writing application : Lavf52.102.0
Writing library : VirtualDub build 32842/release

Video
ID : 0
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High 4:4:4 Predictive@L4.0
Format settings, CABAC : No
Format settings, ReFrames : 8 frames
Codec ID : H264
Duration : 4mn 53s
Bit rate : 7 600 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.275
Stream size : 265 MiB (84%)
Writing library : x264 core 114 r1913bm 5fd3dce
Encoding settings : cabac=0 / ref=8 / deblock=0:0:0 / analyse=0x3:0x133 / me=umh / subme=9 / psy=0 /
mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 /
chroma_qp_offset=0 / threads=2 / sliced_threads=1 / slices=2 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 /
bframes=0 / weightp=0 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc=cqp / mbtree=0 / qp=0

I didn't have problems in Vimeo with my usual default x264 encode (specks 2)

ViciousXUSMC
12th July 2011, 11:48
I started to have some videos fail to work on youtube and I was able to track it down to b-pyramid. Youtube videos use 3 reference frames and they use b-frames so I just limit my stuff to a max of 3 b-frames and taking out b-pyramid and all is well.

As far as settings for video game footage these are the things that come to mind for me.

> Using a good motion estimation due to the very fast movement and lots of motion in many games specially FPS games. I use multi-hex and up the ME Range to 20-24
> Games can make good use of Psy Trellis due to the very sharp nature of the edges I use 1.0/0.5 but thinking about raising it to 1.0/1.0
> Deblock filter is great in x264 but for games again due to the super sharp edges and much higher detail than there is in film I always reduce the deblock to -1/-1 or -2/-2 depending on the game.
> Maybe I dont need to do this but I also disable fast p-skip since there are a lot of dark areas and gradients often due to how shadows are rendered in games.

LoRd_MuldeR
12th July 2011, 11:58
I started to have some videos fail to work on youtube and I was able to track it down to b-pyramid. Youtube videos use 3 reference frames and they use b-frames so I just limit my stuff to a max of 3 b-frames and taking out b-pyramid and all is well.

AFAIK, Youtube will re-encode your video anyway. As long as they can decode what you are uploading, everything should be fine.

Just make sure you upload a high quality source, so you don't have avoidable losses even before their re-encode...

> Using a good motion estimation due to the very fast movement and lots of motion in many games specially FPS games. I use multi-hex and up the ME Range to 20-24
> Games can make good use of Psy Trellis due to the very sharp nature of the edges I use 1.0/0.5 but thinking about raising it to 1.0/1.0
> Deblock filter is great in x264 but for games again due to the super sharp edges and much higher detail than there is in film I always reduce the deblock to -1/-1 or -2/-2 depending on the game.

That basically is "--preset veryslow" with "--tune film", only that the tune option wouldn't crank up Psy-Trellis (second parameter of --psy-rd) that much .

> Maybe I dont need to do this but I also disable fast p-skip since there are a lot of dark areas and gradients often due to how shadows are rendered in games.

Probably a placebo:
http://forum.doom9.org/showpost.php?p=1384029&postcount=7

ViciousXUSMC
13th July 2011, 10:22
Heh the lord has spoken :D

I just found out that fast p-skip was updated so that its not really a big deal any more yesterday. So I have it enabled again.