PDA

View Full Version : How do you make your x264 encodes look good?


oddball
13th November 2006, 02:13
First off an apology to those I may have insulted in my earlier threads. Also sorry for posting in more than 1 place about my problems. Patience is not one of my virtues...

With that out of the way I'd like to know how I can get the best encodes from x264. I did a comparison of a 2 pass x264 encode against an XviD encode at input res and the XviD encode looked substantially better.

I've been trawling around looking for the correct Mencoder command line to get a really good x264 encode but thus far cannot find much that is relevant. It would seem a lot of people are using ffmpeg or GUI's instead.

I've barely been able to get to grips with Mencoder and the GUI's seem well...not very good (Ether that or I cannot get them to run. MeGUI will not run at all for me for some reason). I don't really want to learn ffmpeg since I am so far down the road learning the Mencoder options. Unless there is a BIG reason to choose ffmpeg over Mencoder that is.

I just need to output x264 transcoded from an H.264 BBC HD stream (Easier said than done though). I can get a decent output using an XviD command line I pinched from another thread. But x264 is meant to be better right? Using a simple 2 pass command line my x264 encodes look blocky in comparison to XviD at twice the bitrate or more. So I must be missing some extra x264 surely.

Can someone give me some example quality x264 command line for Mencoder?

Thanks in advance.

EDIT: I should really include the command lines I have tried so perhaps you can correct me.

What I used for 2 pass XviD
---
mencoder -sws 2 -alang eng -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:vhq:vpass=1 -ffourcc XVID -vf pp=lb,scale=1440:1080 -ofps 25 test.ts -o "pass1.avi"

mencoder -sws 2 -alang eng -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:vhq:vpass=2 -ffourcc XVID -vf pp=lb,scale=1440:1080 -ofps 25 test.ts -o "out.avi"
---

What I have tried for 2 pass x264 (I pinched some lines from someplace but they do not seem to work in both passes).
---
mencoder test.ts -ofps 25 -vf scale=1440:1088,pp=lb -alang eng -oac copy -ovc x264 -

x264encopts

pass=1:crf=22:psnr:8x8dct:mixed_refs:b_pyramid:frameref=10:weight_b:bframes=3:subq=6:brdo:bi

me:nofast_pskip:turbo=1 -o pass1.avi

mencoder test.ts -ofps 25 -vf scale=1440:1088,pp=lb -alang eng -oac copy -ovc x264 -

x264encopts

pass=2:psnr:8x8dct:mixed_refs:b_pyramid:frameref=10:weight_b:bframes=3:subq=6:brdo:bime:nofa

st_pskip:bitrate=8000 -o out.mkv
---

EDIT2: Awwww carp! How do I put the command lines in a box so it does not mess up the page?

pyrates
13th November 2006, 02:56
First off an apology to those I may have insulted in my earlier threads. Also sorry for posting in more than 1 place about my problems. Patience is not one of my virtues...

With that out of the way I'd like to know how I can get the best encodes from x264. I did a comparison of a 2 pass x264 encode against an XviD encode at input res and the XviD encode looked substantially better.

I've been trawling around looking for the correct Mencoder command line to get a really good x264 encode but thus far cannot find much that is relevant. It would seem a lot of people are using ffmpeg or GUI's instead.

I've barely been able to get to grips with Mencoder and the GUI's seem well...not very good (Ether that or I cannot get them to run. MeGUI will not run at all for me for some reason). I don't really want to learn ffmpeg since I am so far down the road learning the Mencoder options. Unless there is a BIG reason to choose ffmpeg over Mencoder that is.

I just need to output x264 transcoded from an H.264 BBC HD stream (Easier said than done though). I can get a decent output using an XviD command line I pinched from another thread. But x264 is meant to be better right? Using a simple 2 pass command line my x264 encodes look blocky in comparison to XviD at twice the bitrate or more. So I must be missing some extra x264 surely.

Can someone give me some example quality x264 command line for Mencoder?

Thanks in advance.

EDIT: I should really include the command lines I have tried so perhaps you can correct me.

What I used for 2 pass XviD
---
mencoder -sws 2 -alang eng -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:vhq:vpass=1 -ffourcc XVID -vf pp=lb,scale=1440:1080 -ofps 25 test.ts -o "pass1.avi"

mencoder -sws 2 -alang eng -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:vhq:vpass=2 -ffourcc XVID -vf pp=lb,scale=1440:1080 -ofps 25 test.ts -o "out.avi"
---

What I have tried for 2 pass x264 (I pinched some lines from someplace but they do not seem to work in both passes).
---
mencoder test.ts -ofps 25 -vf scale=1440:1088,pp=lb -alang eng -oac copy -ovc x264 -

x264encopts

pass=1:crf=22:psnr:8x8dct:mixed_refs:b_pyramid:frameref=10:weight_b:bframes=3:subq=6:brdo:bi

me:nofast_pskip:turbo=1 -o pass1.avi

mencoder test.ts -ofps 25 -vf scale=1440:1088,pp=lb -alang eng -oac copy -ovc x264 -

x264encopts

pass=2:psnr:8x8dct:mixed_refs:b_pyramid:frameref=10:weight_b:bframes=3:subq=6:brdo:bime:nofa

st_pskip:bitrate=8000 -o out.mkv
---

EDIT2: Awwww carp! How do I put the command lines in a box so it does not mess up the page?

Use the insane profile for maximum quality. 2 pass is good enough for now. Plus using avisynth to clean it up is good too if it's coming from a 1080i source. By the way, you do the code thing with this:

test

Sharktooth
13th November 2006, 03:15
Use the [Code] tag

oddball
13th November 2006, 03:42
Thank you! :)

BTW doesn't the insane profile relate to MP3 rather than video? I am doing direct copy of the AC3 audio file.

nm
13th November 2006, 08:14
pass=1:crf=22
Either do a one pass constant quality encode by specifying crf=22 or do a 2-pass encode with pass=1:bitrate=8000. Do not use both pass =x and crf simultaneously. Now you're messing up the rate control with your first pass command line. (Or have you checked that crf=22 results in a bitrate of 8000 kbps? In that case your method would be fine.)

About whether to use MEncoder or ffmpeg; I find MEncoder a lot easier to use with its filters. FFmpeg may currently have slightly better MP4 output, but you can always use raw H.264 elementary stream output with MEncoder and mux with MP4Box, for example.

Manao
13th November 2006, 08:56
Additionnaly, I'm curious about the PSNR you got with the x264 encoding. And can you post screenshots of the source and both XviD and x264 encoding ?

Finally, -vf scale,pp=lb ? shouldn't it be lb, then scale ? ( I know it shouldn't make a difference, but it's for consistency's sake with XviD's command line ). Furthermore, the sws 2 disappeared between XviD and x264.

oddball
13th November 2006, 15:21
The PSNR I got from a google of someone elses options. I switched the pp=lb around like you suggested and added 'sws 2' to the x264 encode which I now now is bicubic. It's an hour long video I am encoding right now so it will take some time before I have a result.

nm
13th November 2006, 16:02
Manao meant the actual PSNR values that x264 prints after encoding. PSNR is a measure of signal quality (in this case video quality). The x264 psnr option is just used to switch the printout on and off.

oddball
13th November 2006, 19:00
Oh OK. Well I will take a look at the log after it finishes and paste here if needed. I was comparing an earlier x264 to XviD anyhow and noticed that XviD does that weird smeary blocking on plain background (Walls behind people etc) wheras x264 just seems to block. I now actually find the x264 encodes less jarring. The H.264 captures once you remove the .TS drivel (PID stuff) are a little bit smaller than I first thought. I want to transcode to something smaller but it will definitely mean dropping to half the res (1080i to 720P) to keep the quality reasonable anyhow. My PC can just about decode H.264 .TS video but only when I turn off deblocking and run with DirectShow interlacing (Hoping CoreAVC 1.2 fixes the problem with DShow deinterlace and speeds up decoding a bit more).

If the .TS files were smaller I probably would not transcode at all and just remux to get rid of excess wasted PID's etc. Roll on cheap HD/BR recordable media.