Log in

View Full Version : x264 encoding: CRF + Max Quantizer Question


Makaveli84
20th September 2013, 00:30
Hello,
I am transcoding a piece of video (let's call it V2) to juxtapose it with another one (V1), without having to reencode the first piece (i.e V1). I've done this before with various tools and in different situations, and it almost always works when working on GOP boundaries. Most of the time, I have to strictly adhere to V1's x264 encoding settings when transcoding V2 in order to append V2 to V1 (I usually mux them to mkv and use mkvmerge to append).
This all brings me to my current question: I have a case where V2 can only be appended successfully to V1 when transcoding it, like V1, in CRF=23 mode (also many other settings have to be the same, but that's another discussion). So would dropping the max quantizer to 25, as a compensation for the relatively low quality CRF, cause any problems? Would it be advisable, or not, or it doesn't matter? Also, what other settings should I look out for when dropping max q to 25?
If it makes any difference, min q is set to 0 (I guess this is default automatic).

So??

Dark Shikari
20th September 2013, 00:42
Might I suggest using the --stitchable option? This will let you stitch together two videos of different CRFs.

Makaveli84
20th September 2013, 00:59
First, thanks for the info. I didn't know about this option :).
Second, will this work if this option wasn't set on V1 (the first video which I don't want to transcode)? Will it suffice to set it when transcoding V2?
Third, I don't like change too much, so I'll almost always stick with the tools I'm using (and more often than not, it's GUIs with no option to add command line settings). So for such cases, what would the answer(s) regarding my first post question(s) be?

Thanks!!


Edit: Also, in case of lowering the max q to 25, should I set q step to 3 rather than 4?

Makaveli84
20th September 2013, 13:22
Anyone? Where are all the experts at??

Anyways, the stitching part is pretty much solved, but my general question regarding max q in CRF mode remains, so allow me to rephrase it: if for any reason one is forced to use a certain CRF (say 23), are there any drawbacks to lowering the max q value to 25? Will this cause any negative effects in certain areas or frames of the video? And would it be logical in such a scenario to drop the q step value from the default 4 to 3 or even 2??

detmek
20th September 2013, 16:17
No negative effects. You might get bigger file without noticeable increase in quality. And you don't need to change q step value.

Makaveli84
20th September 2013, 16:58
You might get bigger file without noticeable increase in quality.
I don't understand how can that be. I mean I ran the encode 3 times at CRF 23 and q min-max at [0-51], [0-30] and [0-25], and I got stream sizes X, 1.03 X, and 1.52 X respectively. Without a thorough analysis, one could deduce that around half the frames were encoded at Q=25 rather than Q=28~32 probably, which in turn means that around half the video was encoded at the equivalent of CRF 19 or 20. So in such a scenario, improbable in practice as it may seems, and if what you say is legit regarding no negative effects, then lowering q max value will increase quality. As for it not being noticeable, well it's the equivalent of a few CRFs on a considerable number of frames, so I don't know. Maybe, maybe not...

benwaggoner
20th September 2013, 17:38
No negative effects. You might get bigger file without noticeable increase in quality. And you don't need to change q step value.
What data is --stitchable adding to the bitstream?

nhakobian
20th September 2013, 19:08
What data is --stitchable adding to the bitstream?

https://github.com/DarkShikari/x264-devel/commit/8c8b46f1fbcf1c4b684afff9160d074077909965

If you scroll to the very bottom with the diff in x264.h it has a more complete description of what this option enables to ensure that two bitstreams can be joined.

Vospi
19th December 2016, 17:34
I'm not keen on any coding whatsoever, but for anyone who wants to try this great plugin out, here's the script to compare your source to "grain optimized" version.

Usage for complete beginners:
• get fft3dgpu, TTempSmooth and GrainOptimizer from here (http://avisynth.nl/index.php/External_filters)
• install them to your avisynth plugins folder
• replace paths in my first 4 lines to match your paths
• and insert your source instead of mine in the path that begins with "original=FFVideoSource"

LoadPlugin("C:\Program Files (x86)\MeGUI_x86\tools\ffms\ffms2.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\TTempSmooth.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\FFT3dGPU.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\GrainOpt.dll")

original=FFVideoSource("D:\movies\!ptp\source-blackchristmas-lossless.mkv")

original
FFT3DGPU(sigma=10)
TTempSmooth()
filtered=last

GrainOptimizer(original,filtered)
opt=last

interleave(original,opt)