Log in

View Full Version : Encoding with x264 - Video Quality


Eretria-chan
27th May 2007, 15:29
I had some questions...
I'm currently trying to encode a DVD movie I backed up with x264 (generally through megui).
The movie is anamorphic widescreen (720 x 576), which I cropped to 704x424 and resized to 704x432 (for mod16).
I'm testing different resolutions / bitrate, by downsizing the movie and encoding, to use less bits... but I practically want to keep the encode at DVD quality...
Are there any guidelines as to how much it can be downsized without sacrifcing too much? I'm trying to hit about 1000 kbps. 1500 kbps seems to be fine for the anamorphic resolution, and 1000 seems fine with some blocking.

I was wondering - is it a good idea to keep the anamorphic resolution when encoding and set correct aspect ratio after so the correct resolution is attained, as in like what DVD players do? Or should I resize to correct resolution before encoding?
Is it a good idea to encode @ 1000 kbps or downsize to reduce the blocking? Will it work? Maybe I should set the deblocking a little big more aggressive?
Or is it too much to ask?

I was also wondering about PSNR & SSIM... without taking a direct peek at the movie, can it be considered like an alright way to measure the quality of the encode? I tried 4 different encodes and got these results:

Insane @ 1000:
x264 [info]: SSIM Mean Y:0.9840167
x264 [info]: PSNR Mean Y:49.002 U:51.692 V:51.403 Avg:48.905 Global:45.869

Slow @ 1000:
x264 [info]: SSIM Mean Y:0.9831478
x264 [info]: PSNR Mean Y:48.796 U:51.567 V:51.170 Avg:48.730 Global:45.527

Slow @ 2000:
x264 [info]: SSIM Mean Y:0.9894782
x264 [info]: PSNR Mean Y:50.998 U:52.827 V:52.756 Avg:50.874 Global:48.110

Insane @ 2000:
x264 [info]: SSIM Mean Y:0.9900939
x264 [info]: PSNR Mean Y:51.388 U:53.050 V:53.249 Avg:51.116 Global:48.457

PSNR differs by 2-3 dB. SSIM different not quite by even 0.01!
They were encoded @ 704x432. Is 2-3 PSNR signifant? Is the SSIM difference significant?
Thanks for any answers.

J_Darnley
27th May 2007, 15:57
The filesize/quality/blocking issue is subjective. I personally resize to 1:1 sample aspect ratio. For series encodes I usually slightly overcrop by about 2 pixels on every side and then resize to 640 width. For the few movies I've done, I've cropped to 704 wide and whatever off the top and bottom and then just vertically resize to closest height.

For the actual encoding I use --crf 18 which gives acceptable quality for me. I also use -2,-1 deblocking which has caused some very noticable blocking on backgroung walls in Stargate Command. --crf 18 has given me sub 1000 kbit bitrates for 640w Stargate encodes and when I was encoding LOTR I got bitrates in the range 1000-1500 as I used LimitedSharpen to sharpen it up a bit.

If I had a better display I might keep it the anamorphic resolution but I think that the little bit extra detail is not worth it when compare them in fullscreen.

As for the PSNR and SSIM measures. From what I have read, the PSNR is almost worthless for comparing two encodes as it is purely mathematical using the standard error, I think. The SSIM is better in that it uses a different quality measure that matches up more with human perception. I wouldn't use either of them to decide on what settings to use. I would definately look at the video to decide. Flat areas, high random motion are good places to look for differences between clips.

To help with choosing your deblocking values, look at *.mp4 guy's AVC Deblocking FAQ (1,825,629,636).

Eretria-chan
27th May 2007, 16:56
TFor the actual encoding I use --crf 18 which gives acceptable quality for me. I also use -2,-1 deblocking which has caused some very noticable blocking on backgroung walls in Stargate Command. --crf 18 has given me sub 1000 kbit bitrates for 640w Stargate encodes and when I was encoding LOTR I got bitrates in the range 1000-1500 as I used LimitedSharpen to sharpen it up a bit.
But --crf is variable one-pass mode, is it not? I use 2-pass.

If I had a better display I might keep it the anamorphic resolution but I think that the little bit extra detail is not worth it when compare them in fullscreen.
Not sure if I follow on that one...
If encoding in anamorphic, I save precious bits, and then I strech the video back on playback. Anamorphic doesn't give extra detail... it's less detail, so I don't understand what you mean, really...

As for the PSNR and SSIM measures. From what I have read, the PSNR is almost worthless for comparing two encodes as it is purely mathematical using the standard error, I think. The SSIM is better in that it uses a different quality measure that matches up more with human perception. I wouldn't use either of them to decide on what settings to use. I would definately look at the video to decide. Flat areas, high random motion are good places to look for differences between clips.
Of course, I won't substitute it entirely... all I want is a good way of knowing if there are significant changes in quality worth investigating. A little less detail here and there can be hard to spot.

J_Darnley
27th May 2007, 18:38
But --crf is variable one-pass mode, is it not? I use 2-pass.
Exactly, it's quicker. I'm not bothered by final file size, I don't burn my encodes to a CD or DVD, I store them on a HDD

Not sure if I follow on that one...
If encoding in anamorphic, I save precious bits, and then I strech the video back on playback. Anamorphic doesn't give extra detail... it's less detail, so I don't understand what you mean, really...
Sorry, maybe I wasn't very clear. I downsize the video to a 1:1 SAR. I lose some detail when I do this. I usually resize to 640x352 or 704x288 from 720x576.

Of course, I won't substitute it entirely... all I want is a good way of knowing if there are significant changes in quality worth investigating. A little less detail here and there can be hard to spot.
Well a PSNR of 3 dB lower should have twice as much noise. As for SSIM, I have no idea what changes are significant. I would assume that it is linear, in a fashion, and assume that a <1% difference is negligable. I would then weigh the difference based upon encoding time and filesize. I would probably choose the quicker smaller one if it had no apparent difference. All I can suggest is that you test it out yourself with SelectRangeEvery(1500, 250) for 1/6 of your movie (10 sec every minute).

Eretria-chan
27th May 2007, 18:45
Exactly, it's quicker. I'm not bothered by final file size, I don't burn my encodes to a CD or DVD, I store them on a HDD
Size usually matters to me... One pass is just no-go for me. I always use 2-pass for best quality.

Sorry, maybe I wasn't very clear. I downsize the video to a 1:1 SAR. I lose some detail when I do this. I usually resize to 640x352 or 704x288 from 720x576.
Well, I could downsize, while keeping aspect ratio. Sure, I can do that, if it doesn't hurt quality too much.

Well a PSNR of 3 dB lower should have twice as much noise. As for SSIM, I have no idea what changes are significant. I would assume that it is linear, in a fashion, and assume that a <1% difference is negligable. I would then weigh the difference based upon encoding time and filesize. I would probably choose the quicker smaller one if it had no apparent difference. All I can suggest is that you test it out yourself with SelectRangeEvery(1500, 250) for 1/6 of your movie (10 sec every minute).

I might... I had no luck with a 1000 kbps encode. I may have to up it a bit. Between 1000 - 1500 seems to be the sweet spot I think. I'm still having trouble with the audio, though...

Manao
28th May 2007, 12:54
Well a PSNR of 3 dB lower should have twice as much noiseNo. It will be less detailed, and less noisy. Don't be fooled by the name of the metric.As for SSIM, I have no idea what changes are significant. I would assume that it is linear, in a fashion, and assume that a <1% difference is negligableNo, completely wrong. see :

http://forum.doom9.org/showthread.php?p=998524#post998524
http://forum.doom9.org/showthread.php?p=998815#post998815