Log in

View Full Version : x264 very good quality and smallest size?


firebo14
26th December 2011, 00:21
Sorry for this very newbie question...

The x264 settings are a bit hard to understand... what is the x264 settings for very good quality (by the human eye) and smallest size? I do not want lossless, it is too big.

Thanks... :):D

LoRd_MuldeR
26th December 2011, 00:26
Sorry for this very newbie question...

The x264 settings are a bit hard to understand... what is the x264 settings for best quality (by the eye) and smallest size? I do not want lossless, it is too big.

Best possible quality, by definition, is lossless. Consequently your question is contradictory!

And even if you don't want "best" quality (lossless), but just "very good" quality (like "transparent" quality), it should be clear that you can get this and "smallest size" at the same time :rolleyes:

Video compression always is a trade-off between quality (compression artifacts) and file size (bitrate). Though using "slower" settings can improve the "quality per bit" ratio.

Consequently, using the slowest x264 preset that you can afford speed-wise in combination with the highest CRF value that you can accept quality-wise, is as close as possible to what you want.

Using the suitable tuning option for the type of your source certainly doesn't hurt either. Pre-processing, like strong denoising, can further reduce the bitrate requirement...

firebo14
26th December 2011, 00:43
Oh hey again LoRd_MuldeR .

Ah, sorry... i meant 'very very very very very very very good' (yes, 7 'verys') as in the human eye would not tell the difference. I am using a different encoder, the command prompt version (from http://www.x264.nl/). I am new to this command prompt.

May u post the 'very very very very very very very good' command line settings? Oh please, Lord or someone. :D

And in this here (http://mewiki.project357.com/wiki/X264_Settings#psnr), does psnr, ssim, deblock, and many others improve quality and smaller size?

Thanks again for your help :D

LoRd_MuldeR
26th December 2011, 00:57
There is no exact/universal definition of "visually lossless" quality, because everybody can have his/her own opinion on this :rolleyes:

So do what has been suggested before: Encode with CRF mode and use the highest possible CRF value that still meets your quality requirements.

Something like CRF=16 will certainly give you very good quality. In case that still doesn't satisfy you, try 14 or 12. And so on.

If you want to keep the bitrate as low as possible at the same time, encode with the slowest preset that you can accept speed-wise. It's as simple as that.

But keep in mind that CRF mode only gives approximately(!) the same quality for the same CRF value as long as you don't change other influential settings.

Consequently you may need to rescale your CRF value after switching to a different preset!


Commandline:
x264.exe --preset <preset_of_your_choice> --tune <tune_that_matches_your_source> --crf <crf_value_of_your_choice> -o <output> <input>
Just one example:
x264.exe --preset veryslow --tune film --crf 16 -o "c:\foo\encoded.mkv" "c:\foo\source.avs"


You don't have to worry about any other commadline switches, unless you have additional requirements, such as BluRay compatibility for BluRay authoring.

The options that effect 'quality -vs- speed' or tweak x264 for a specific source-type are already covered by the preset/tuning system.

BTW: SSIM and PSNR are quality metrics. They can give a (very rough!) estimate of the quality of your encode, but they don't change the output (details (https://ece.uwaterloo.ca/~z70wang/publications/SPM09.pdf)).

CarlEdman
26th December 2011, 04:48
Lord_Mulder, as usual, is absolutely right.

I have used nearly identical setting for years (as you have heard, except crf 17, rather than 16--the trade-off between size and quality is just a little different for everybody; many consider crf 18 to be transparent and find even higher values acceptable).

For what it is worth, on a Core 2 i970 (6 cores, 12 threads), with a demanding avisynth script (including MDegrain3), these settings typically encode in about real-time for SD (e.g., DVD resolution) and about one fifth of real-time for telecined HD content, i.e., 1080p24 (though I use a substantially higher crf for HD sources).

vrpatilisl
31st December 2011, 11:07
hi
I also strugled to get this done. As the expert say crf 18 gives best result. I tried lossles it is useless time and space wise. i have compared some presets in megui and vidcoder very slow preset and it shows me that extra quality preset (sharktoth) given best quality to size. See the attach.

firebo14
1st January 2012, 06:57
Thanks, LoRd_MuldeR and Carl Edman.. :]

hi
I also strugled to get this done. As the expert say crf 18 gives best result. I tried lossles it is useless time and space wise. i have compared some presets in megui and vidcoder very slow preset and it shows me that extra quality preset (sharktoth) given best quality to size. See the attach.

Useful... thanks... :thanks:

If anybody finds more very good settings, please post here. :D

vrpatilisl
1st January 2012, 07:16
hi
best setting according to me in Megui
.Crf 18 with sharktooth 1pass extra quality /insane(if u got time) preset, to get transperent Dvd rips

LoRd_MuldeR
6th January 2012, 19:30
hi
best setting according to me in Megui
.Crf 18 with sharktooth 1pass extra quality /insane(if u got time) preset, to get transperent Dvd rips

Giving your preset a fancy name doesn't change the output to the better at all :p

You can probably achieve the same with an ordinary:
x264.exe --preset veryslow --tune film --crf 18

(Or, if encoding time really doesn't matter for you at all, replace "veryslow" with "placebo")

firebo14
7th January 2012, 03:46
Thanks, Lord MuldeR, i will take your words because u are a Software Developer. :D:cool:
:thanks:

Ghitulescu
7th January 2012, 08:56
I frankly don't understand why people keep on asking this: What settings give the best (very good, etc.) quality at the smallest file size?
Who's gonna encode for the lowest quality and biggest size? Or at the same quality (:p) at a higher file size? People suffering from Horror vacui?

The reason these parameters exist is to give one the freedom to set the encoder to suit his best interest (not ALWAYS the smallest size). You're unhappy to experiment yourself, then pick up the first link in google, you only have to press three buttons three times: Select source, Select destination, Go/Run, these software will pick automatically the best profile for you :p.

LoRd_MuldeR
7th January 2012, 15:03
Well, x264 has quite a huge number of options that can be tweaked. And it's easy to ruin your encode with inconsiderate parameter modifications :scared:

If you are new to x264 (or video encoding as a whole) it's hard to understand which settings can/should be tweaked for what reason - and which better should not be touched.

To make things worse, you'll find loads of "recommendations" about x264 settings on the net - some are well-grounded, some are outdated nowadays and some are just misleading/nonsense.

Also not everybody has the "scientific background" and/or the motivation to run in-depth tests with all possible parameter combinations ;)

After all, the built-in Preset and Tuning system make things a lot easier for everybody. Most users should never need to overwrite anything, just pick your Preset/Tuning and be happy.

One problem is that many GUI front-end's for x264 still implement their own Preset system - rather than just passing through the user's Preset choice to x264...

(Implementing presets in the GUI program might have been a great feature before x264's own Preset system was available, but it's just redundant and confusing nowadays)

firebo14
7th January 2012, 16:59
After all, the built-in Preset and Tuning system make things a lot easier for everybody.

Well said, LoRd MuldeR, as usual.... :D

I frankly don't understand why people keep on asking this: What settings give the best (very good, etc.) quality at the smallest file size?

...best interest (not ALWAYS the smallest size)

That is the main reason why we have H264, it is to save space while maintaining transparent quality. Having the smallest size is the best there is... who wants a giant uncompressed video that is like 357 times bigger?.... D:

:D

Ghitulescu
7th January 2012, 20:48
That is the main reason why we have H264, it is to save space while maintaining transparent quality. Having the smallest size is the best there is... who wants a giant uncompressed video that is like 357 times bigger?.... D:

All codecs were designed with this purpose in mind :) ;) incidentally. And you removed from my quote exactly the phrase stating the same thing.

However, there are two fundamental approaches:

1. existing bit budget constrains: the final size is known, so the average bit rate, the only issue is to find the right parameters to distribute these bits according to the complexity of the scenes, so the final video would look as transparent as possible in these conditions

2. quality issues constrains: one has the "transparent" thing in mind and tweaks the settings accordingly, however the end video size is not known beforehand, only guesstimated.

Of course one can encode 3hours of FullHD into 700MB final size by keeping the quality "transparent", just that the same one has to redefine the meaning of "transparent". :)

And of course Lord_Mulder is right, just read all that he said, not just the convenient bits thereof.

hello_hello
8th January 2012, 15:18
However, there are two fundamental approaches:

1. existing bit budget constrains: the final size is known, so the average bit rate, the only issue is to find the right parameters to distribute these bits according to the complexity of the scenes, so the final video would look as transparent as possible in these conditions

2. quality issues constrains: one has the "transparent" thing in mind and tweaks the settings accordingly, however the end video size is not known beforehand, only guesstimated.

So you're saying if you want to keep the file sizes down you need to tweak x264's settings regardless of which method you use?
I'd be interested to know which settings can be tweaked to reduce the file size while maintaining the quality and/or why they're not the default settings.
I'm not saying there aren't ways to tweak the encoder to reduce the file size while maintaining quality... I don't actually know (aside from using the speed presets).

Ghitulescu
9th January 2012, 15:44
It'd be interested to know which settings can be tweaked to reduce the file size while maintaining the quality and/or why they're not the default settings.
I'm not saying there aren't ways to tweak the encoder to reduce the file size while maintaining quality... I don't actually know (aside from using the speed presets).

For instance b-pyramids and reference frames, but increasing their number too much will make the video incompatible with the Blu-ray standard, and consequently playable only on a PC. Also the widespread technique of cropping out the black mattes will save some bits (thus space, much less than one may hope ;)) but again this will render the file incompatible with some standards.

So the smallest file size is not always a requirement.

hello_hello
10th January 2012, 02:12
I don't know why it's always just Bluray player vs PC. Bluray players and PCs aren't the only two devices capable of playing video. A quick look at MeGUI's x264 configuration dialogue indicates the PS3 and WDTV can both play video well outside of the official Bluray standard, as I suspect can many Bluray players capable of playing alternative file types. I'm fairly confident mine will, as will the media players in the TVs.

I'd agree with LoRd_MuldeR. Unless you really know what you're doing it pays to simply stick to x264's own presets. B-frames and reference frames etc seem to be adequately covered. When it comes to device compatibility... well you need to know what a device will and won't play whether you tweak x264's settings or not. I find that's where a decent GUI can be useful if you're not sure which encoder settings are required. In the case of MeGUI it'll let you change the x264 preset (or fiddle with x264's settings manually) but selecting a target device option will get MeGUI to add to the command line whichever parameters are required for that device. As best as I can tell they're generally parameters relating to profile, frame type or rate control. Settings which don't effect hardware compatibility are left alone. Personally I just stick to x264's speed presets and whatever MeGUI adds for device compatibility as I'm not expert enough to fiddle with x264's parameters manually. I doubt the majority of people would be.

Remicade
21st February 2012, 15:37
I made some tests, i encode a sample (1080p) with presets ultra, medium, slow in MeGUI, I extract the same frame and compare. For an "amateur eye" I don't see any diference.

LoRd_MuldeR
21st February 2012, 15:52
I made some tests, i encode a sample (1080p) with presets ultra, medium, slow in MeGUI, I extract the same frame and compare. For an "amateur eye" I don't see any diference.

You were comparing output files of identical size (identical average bitrate), right?

But even then, your observation only means that the test was done at a bitrate at which even the Ultrafast preset gave good quality.

If you pick a bitrate at which even the "fastest" preset in the test gives "transparent" quality, then the "slower" presets can not look even better ;)

However the conclusion that there is no difference would be wrong. At a lower bitrate the difference would probably be visible...

(If we didn't consider the bitrate, we could use MPEG-2, crank up the bitrate to get excellent quality and conclude that H.264 is no better ^^)

diogen
21st February 2012, 16:06
I made some tests, i encode a sample (1080p) with presets ultra, medium, slow in MeGUI, I extract the same frame and compare. For an "amateur eye" I don't see any diference.Outcomes of tests like this are very dependent on:
- material (animation, film, video, etc.)
- source (MPEG-2, -4, etc.)
- make (CGI, RED, film, etc.)
- grain
- player (computer, PCH-type media player, BD player, etc.)
- TV/projector (calibrated?)
- experience...

Diogen.

ramicio
18th April 2012, 15:00
If you pick a bitrate at which even the "fastest" preset in the test gives "transparent" quality, then the "slower" presets can not look even better ;)

What I'm gathering by this statement is that if you use slower presets, quality will decrease because the bit-rate will decrease.

prOnorama
18th April 2012, 16:27
What I'm gathering by this statement is that if you use slower presets, quality will decrease because the bit-rate will decrease.

I have a different interpretation: if the quality is "transparent" at a given bitrate, quality will remain the same at a lower bitrate when using slower presets. The reduction in bitrate is compensated by settings in slower profiles which also influence quality.

ramicio
18th April 2012, 16:33
That was my understanding of how it works, but now how he worded it. Slower presets allow the same quality for a lower bit-rate, at the expense of encoding speed. I am working on tests today on a 5-minute clip, between presets and amount of threads. If I let it do auto, it uses 18 threads. So far, for the medium preset, the difference in file size between 4 and 16 threads is ~3.3 MiB, and on the veryslow preset, ~3.3 MiB, also. Placebo actually ended up larger than veryslow and taking many times longer, so I won't even consider it. I'm doing a test with 1 thread now. In CRF, are more threads a loss in quality, or just a loss in compression efficiency?

Asmodian
18th April 2012, 18:52
If you pick a bitrate at which even the "fastest" preset in the test gives "transparent" quality, then the "slower" presets can not look even better ;)

However the conclusion that there is no difference would be wrong. At a lower bitrate the difference would probably be visible...

What I'm gathering by this statement is that if you use slower presets, quality will decrease because the bit-rate will decrease.

You are misreading it and you left out the next bit that helps with context.

The way I understand it LoRd_MuldeR means that if the video is already "transparent" you cannot tell that it is higher quality, so it isn't; the only important way to measure quality is with your eyes. That said the slower preset is probably higher quality if only you could notice the difference.

Edit: The placebo preset is like this too; it is enough higher quality at a given crf that the size goes up a little. It is still more efficient in quality/size, quality/time it is very bad. ;)

ramicio
18th April 2012, 18:55
The only thing I constantly misread is bad English. I could care less about what people consider transparent. What I want to know is if it will still be the same quality by whatever standard CRF uses to quantize quality.

Asmodian
18th April 2012, 19:20
The only thing I constantly misread is bad English. I could care less about what people consider transparent. What I want to know is if it will still be the same quality by whatever standard CRF uses to quantize quality.

Bad English? That looks like correct English to me.

Remember you cannot use crf to get the same quality using different settings. CRF is constant quality mode at X settings. It is used for rate control inside one video not to set an overall quality.

ramicio
18th April 2012, 19:25
The guy constantly uses off-base English. I still would like a clear answer to my question. Do the presets change the quality of the picture or do they change the efficiency of compression? If it's the former, what is the point of the presets if you have to change your CRF number just to get the same relative quality and end up with the same bit-rate?

Asmodian
18th April 2012, 20:53
Well presets attempt to only change efficiency but of course this isn't completely possible.

The point of crf is to provide single pass rate control that offers equivalent efficiency (quality/size) as two pass rate control without needing two passes.

If there is no good way to measure quality programmatically how the hell do you think crf will be able to get the same quality at any given preset? As soon as you change any setting the quality at a given crf will change some. Some settings have a bigger effect on quality at a given crf than others. Some effect size a lot at a given crf.

Rate control and video quality is a more complicated problem than you seem to think. crf isn't magic but it is very useful. I pick a crf after I chose the rest of the settings.

ramicio
18th April 2012, 20:58
So it's all completely null and void and a giant mess up. It's just pointless to use a CRF of say 17 with no preset applied (medium) than to use the same CRF with a preset of veryslow. Why waste the time slowing down the encode if to get the same quality you will need to just up the CRF to get to the same bit-rate and get an even slower encode? It makes no sense and there needs to be someone to document how this stuff work instead of letting programmers explain it.

Asmodian
18th April 2012, 21:23
So it's all completely null and void and a giant mess up. It's just pointless to use a CRF of say 17 with no preset applied (medium) than to use the same CRF with a preset of veryslow. Why waste the time slowing down the encode if to get the same quality you will need to just up the CRF to get to the same bit-rate and get an even slower encode? It makes no sense and there needs to be someone to document how this crap work instead of letting programmers explain it.
I don't understand what you are asking, except that you seem to think you are owed something?

The slower the preset the higher the quality per size. The lower the crf the higher the quality and larger the size. However these two settings are not independent.

The presets are a collection of settings that affect speed a lot and make sense together. They allow you to set speed without needing to understand the time costs and quality benefits of all the settings.

Example: "-me hex -merange 64" isn't a good use of time. "-me umh -merange 24" is a better idea.

If you don't undersand it just use the preset that is as slow as you can handle and set a crf that gives you the quality you want and let the size be what it is. This is always the advice given by the programers, isn't it? What more do you need to understand?

ramicio
18th April 2012, 22:18
Anyway...what I keep asking is with a given CRF value, when you choose a slower preset, does the quality decrease (because of the bit-rate also decreasing)?

Asmodian
19th April 2012, 00:20
In my experiance the quality goes up with a slower preset at a given crf, even as the file size goes down.

hello_hello
19th April 2012, 07:25
It seems logical to me if you use different compression techniques (slower presets) which increase the efficiency/quality at a given bitrate (2 pass encoding), then the same compression techniques aren't going to reduce the quality for a given CRF value. At worst, the bitrate should just drop a little while the quality remains the same.

If in order to maintain quality you were forced to decrease the CRF value to return the bitrate to what it'd be when using a faster preset, aside from it being fairly pointless to use a slower preset in CRF mode, it'd mean the slower presets aren't increasing the efficiency/quality for a given bitrate in CRF mode as they do in 2 pass mode, which doesn't make sense.

The only thing I constantly misread is bad English. I could care less about what people consider transparent.

Speaking of bad English, "I could care less" is one of my favorites. If you could care less it means you do care to some degree, maybe even a lot. Now if you "couldn't care less"..... ;)

ramicio
19th April 2012, 15:56
In my experiance the quality goes up with a slower preset at a given crf, even as the file size goes down.

Thank you :D

Speaking of bad English, "I could care less" is one of my favorites. If you could care less it means you do care to some degree, maybe even a lot. Now if you "couldn't care less"..... ;)

What is the point of you?

AnonCrow
20th April 2012, 16:57
. Do the presets change the quality of the picture or do they change the efficiency of compression? If it's the former, what is the point of the presets if you have to change your CRF number just to get the same relative quality and end up with the same bit-rate?

Isn't the official answer for that somewhat along the lines of:
When using a fixed CRF and changing preset, both quality and bitrate can change, any which way, depending on the source.

'efficiency' defined as quality per bitrate;
then slower presets should always have the same or better efficiency. Actual quality may be better or worse,
for some sources it might even produce identical quality at a lower bitrate.

Asmodian
23rd April 2012, 22:20
Isn't the official answer for that somewhat along the lines of:
When using a fixed CRF and changing preset, both quality and bitrate can change, any which way, depending on the source.

'efficiency' defined as quality per bitrate;
then slower presets should always have the same or better efficiency. Actual quality may be better or worse,
for some sources it might even produce identical quality at a lower bitrate.

This is true but I also feel safe with "In my experience the quality goes up with a slower preset at a given crf, even as the file size goes down." Of course no guarantee, odd sources can do odd things, but quality is usually very similar or better if one uses a slower preset with a fixed crf.

nakTT
12th December 2012, 05:27
Giving your preset a fancy name doesn't change the output to the better at all :p

You can probably achieve the same with an ordinary:
x264.exe --preset veryslow --tune film --crf 18

(Or, if encoding time really doesn't matter for you at all, replace "veryslow" with "placebo")
Sorry for bring up this old thread. Its been a while since I post here.

Currently I am doing 2-Pass encoding and just want to ask a few questions regarding the preset settings:

Roughly how big (in %) is the extra compression gained going from "Slower" to "Very Slow"? How about going from "Very Slow" to "Placebo"?

Thank you in advance and have a nice day.