Log in

View Full Version : how can you compress lossless specific area


Xma1
24th November 2015, 00:49
Hi all,

I have a project where I is an important area (eg sheet of paper with the text) should compress with good quality in the HEVC video that background but with bad quality.

The range varies from frame to frame, but I know location of each area. How can I tell the HEVC where it qt is set to 0, and where it is on 51.:confused:



Best Regals
Mark Tamaev

Motenai Yoda
24th November 2015, 01:01
try zones
--zones <zone0>/<zone1>/...


Tweak the bitrate of regions of the video. Each zone takes the form:

<start frame>,<end frame>,<option> where <option> is either q=<integer> (force QP) or b=<float> (bitrate multiplier).

If zones overlap, whichever comes later in the list takes precedence. Default none


or qpfile
--qpfile <filename>


Specify a text file which contains frametypes and QPs for some or all frames. The format of each line is:

framenumber frametype QP

Frametype can be one of [I,i,K,P,B,b]. B is a referenced B frame, b is an unreferenced B frame. I is a keyframe (random access point) while i is an I frame that is not a keyframe (references are not broken). K implies I if closed_gop option is enabled, and i otherwise.

Specifying QP (integer) is optional, and if specified they are clamped within the encoder to qpmin/qpmax.

benwaggoner
24th November 2015, 17:57
try zones

or qpfile
Those are per-frame settings, not to define a region in a frame.

The old VC-1 PEP/CineVision PSE had the ability to override settings per macroblock in a frame. It's not conceptually hard, but needs an API and some tweaks (potentially challenging) to the rate control algorithms).

foxyshadis
24th November 2015, 18:57
The only way to do this in x265 is to write a program to call the internal C++ API and set *quantOffsets for each frame, or to modify the command-line to read the data from a file or whatever. There's no way to do it through the standard command-line.

There may be other implementations that build in the capability, I don't know them.

HarryM
25th December 2015, 16:27
If you need it - you can override it by blurring (or using another filter heavily helping to compression, etc.) of the specific area of frame. The blurred area needs logically much less bitrate.

Analogy of this, i was using at divxrip compression - main part of movie resized by lanczos, and begin/final credits by bilinear (bilinear is much more compressible than lanczos).

benwaggoner
27th December 2015, 19:46
Also, if you have highly detailed but static elements that you want to preserve, try --cu-lossless. That will try using lossless encoding for blocks, and pick it if it has the best RDO. It should be helpful for things like line art and other synthetic areas with flat colors, sharp edges, and no noise.

@HarryM, I find area to be better than either for scaling credits for big ratios. With moving text, aliasing errors can wind up being different as sub-pixel alignment varies.

x265_Project
30th December 2015, 05:44
As FoxyShadis alluded to, in the x265 API we have a feature that supports "region of interest optimization". See x265.h, line 214.

/* An array of quantizer offsets to be applied to this image during encoding.
* These are added on top of the decisions made by rateControl.
* Adaptive quantization must be enabled to use this feature. These quantizer
* offsets should be given for each 16x16 block. Behavior if quant
* offsets differ between encoding passes is undefined. */
float *quantOffsets;

We will add the capability to support this (one set of offsets for the whole encode) in the command line when we get a chance.