VVenC

From wiki.selur.net
Jump to navigation Jump to search

VVenC is the open-source encoder of the Fraunhofer Heinrich Hertz Institute for H.266/VVC (Versatile Video Coding), the successor of H.265/HEVC. VVC needs clearly less bit rate than HEVC for the same quality, at the price of long encoding times and still limited player support. Hybrid drives the command line encoder vvencapp.

Base → Video: VVenC, then the VVenC tab

What it does

VVenC works like the other block based encoders: it predicts each picture from already coded pictures or from neighbouring blocks, transforms the remainder and quantizes it. VVC adds larger and more flexibly split blocks and many more prediction tools, which is where both the gain and the encoding time come from. Few of these tools are set one by one; the preset selects them. The rate control offers three modes:

  • quantizer (1-pass): a fixed quantizer (QP). With Adaptive quantization on, the QP is varied inside the picture by a perceptual model, which makes this a constant quality mode; an added maximum rate turns it into capped constant quality.
  • average bitrate (1-pass): one pass towards a bit rate.
  • specific filesize/bitrate (2-pass): a first pass analyses the video, the second distributes a given bit rate or file size over it.

Requirements

vvencapp is part of Hybrid on Windows, Linux and macOS. The encoder appears in the list as soon as the tool is found.

  • VVenC only encodes progressive 4:2:0 video with 8 or 10 bit. Hybrid converts other color formats and deinterlaces interlaced sources on its own.
  • Output containers: MP4, Matroska, TS/M2TS, or the raw stream with the extension .vvc. Other containers (WebM, AVI, MOV) are refused when the job is created.
  • Decoding VVC needs a current player or ffmpeg; hardly any hardware player supports it yet.

Settings

The option column shows the vvencapp option a control ends up as. Entries of the form Name=value are passed inside --additional.

Base

VVenC Base tab
VVenC Base tab
Control vvencapp option Range / values Hybrid default Meaning
Encoding mode --qp, --bitrate, --passes, --pass quantizer (1-pass), average bitrate (1-pass), specific filesize/bitrate (2-pass) quantizer (1-pass) Rate control mode, see above. The controls below it change with the mode.
Quantization strength --qp 0 – 63, step 0.5 20 Quantizer of the quantizer mode; lower keeps more detail and gives bigger files. A fractional value such as 27.5 encodes between the two neighbouring quantizers. Only shown in quantizer mode.
Bitrate (kbit/s) --bitrate 16 – 245760 on, 1500 Target bit rate of the two bit rate modes. In 2-pass mode it is the alternative to Target size. Only shown in the bit rate modes.
Target size (MiB), Target mode --bitrate 0.2 MiB and up; custom, 1/4 CD … 1 BD 50 off; custom, 700 Aim at a file size instead; Hybrid computes the video bit rate from the size, the length and the size of audio and other streams. Target mode offers common media sizes. Only available in 2-pass mode.
Statistic file --rcstatsfile file empty Statistics file of the 2-pass mode; empty uses a temporary file that is removed afterwards. Locked in the other modes.
Profile --profile auto, main_10, main_10_still_picture auto VVC profile written into the stream. auto lets the encoder choose; main_10 covers all video VVenC can encode.
Level --level auto, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2, 6.3 auto Upper limit for frame size, frame rate and bit rate the stream declares. The list only contains levels that are high enough for the output resolution, because the encoder aborts with a lower one. With auto the encoder picks the level and also raises it for high bit rates.
Tier --tier main, high main The high tier raises the bit rate limit of a level. Only available when the level (with auto: the level that fits the resolution) is 4 or higher.
Bit depth --internal-bitdepth 8-bit, 10-bit 10-bit Bit depth the encoder works at and writes. 10 bit is the encoder's default and also the better choice for 8-bit sources.
Adaptive quantization --qpa off, on on Perceptual QP adaptation (based on the XPSNR model): shifts bits to where the eye notices errors. Turn it off only for metric tests or a strictly constant quantizer.
Max rate --maxrate no limit; fixed: 0 – 245760 kbit/s; mult: 1 – 100, step 0.01 no limit; 0; 2 Approximate upper limit of the momentary bit rate. fixed is an absolute value (in the bit rate modes at least the target bit rate), mult a multiple of the target bit rate. In quantizer mode only fixed is offered, and only with Adaptive quantization on (capped constant quality); mult needs a bit rate mode.
Preset --preset faster, fast, medium, slow, slower, medium_lowDecEnergy medium Trade-off between speed and compression. Each step towards slower costs a multiple of the encoding time. medium_lowDecEnergy is medium with settings that are cheaper to decode.

Signaling

VVenC Signaling tab
VVenC Signaling tab

These settings do not change the picture, only the description of the video in the stream.

General Color

Control vvencapp option Range / values Hybrid default Meaning
Range, to input --range limited, full on, to input Value range that is signalled (limited 16 – 235 or full 0 – 255). With to input Hybrid takes the range of the video that reaches the encoder, and the list is locked.
Primaries, to input ColourPrimaries= unknown, bt709, bt470m, bt470bg, smpte170m, smpte240m, film, bt2020, smpte428, smpte431, smpte432 off; to input on Color primaries. unknown writes nothing.
Matrix, to input MatrixCoefficients= unknown, bt709, fcc, bt470bg, smpte170m, smpte240m, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp on, to input Matrix for the YUV ↔ RGB conversion.
Transfer, to input TransferCharacteristics=, --hdr unknown, bt709, bt470m, bt470bg, smpte170m, smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67 off; to input on Transfer function. With smpte2084 (PQ) or arib-std-b67 (HLG) Hybrid also switches the encoder into its HDR mode (--hdr pq / hlg, with bt2020 primaries pq_2020 / hlg_2020), which changes how bits are distributed.
Chroma location -vui 1, ChromaLocInfoPresent=1, ChromaSampleLocType= 0 – 5 off, 0 Position of the chroma samples of 4:2:0 video, e.g. 0 for the usual left position and 2 for UHD BT.2020 material. Forces the VUI to be written.

HDR

Control vvencapp option Range / values Hybrid default Meaning
Light Level, max cll, max fall, from Input MaxContentLightLevel= 0 – 65535 each off; from Input on Content light level SEI: the brightest pixel (MaxCLL) and the highest frame average (MaxFALL) in cd/m². With from Input Hybrid fills the values from the source during analysis. Nothing is written when both values are 0.
Master Display, from Input MasteringDisplayColourVolume= text off; from Input on Mastering display color volume SEI (SMPTE ST 2086) in the form G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min), the same units as in x265: coordinates in steps of 1/50000, luminance in 1/10000 cd/m². It describes the display the video was graded on, so take it from the source. Nothing is written unless the text contains exactly ten numbers.

The pixel aspect ratio comes from Crop/Resize and is written as AspectRatioIdc=255:Sar=WxH when it is not 1:1.

Misc

VVenC Misc tab
VVenC Misc tab

Threading

Control vvencapp option Range / values Hybrid default Meaning
Overwrite threads --threads 1 – 64 off, 1 Fixed number of threads. Without it the encoder decides by resolution: 4 threads below 720p, 8 below 5K, 12 from 5K on.
Multithreading profile --mtprofile auto, off, 1, 2, 3 auto How far the encoder parallelizes (tiles, inter-frame parallelization and wavefront processing are switched on automatically depending on the thread count). More parallelism costs a little compression.
Inter-frame parallelization --ifp auto, off, on auto Lets several frames be encoded at the same time, with an offset of two CTU lines between them.
Tiles (X/Y) --tiles columns × rows; maximum depends on the resolution off, 1 x 1 Splits every frame into a grid of independently coded tiles, which parallelizes well and costs compression at the tile borders. The upper limits follow the output resolution: none (1×1) for small SD sizes, 2×2 up to 720×576, 3×3 up to 1280×720, 5×5 up to 1080p, 10×11 up to UHD, more above.

Other settings

Control vvencapp option Range / values Hybrid default Meaning
Refresh type --refreshtype cra, idr, cra_cre, idr_no_radl cra Picture type at every intra period. cra is an open GOP (the encoder's default), idr a closed GOP, cra_cre a CRA with constrained leading pictures, idr_no_radl an IDR without leading pictures, meant for DASH.
Intra period --intraperiod (frames), --refreshsec (seconds) frames: 1 – 10000; seconds: 1 – 60 frames, 250 Distance between two refresh pictures, as a frame count or in seconds. Only the box of the chosen unit is active.
Film grain analysis --fga off, VTM, VTM + temporal, VTM + temporal + AR off Experimental. Analyses the grain of the source and writes it as film grain characteristics SEI, from which a decoder can synthesize grain. VTM is the analysis of the reference encoder, temporal also measures the grain from the temporal residual, AR adds the auto-regressive grain model. Not every decoder uses the SEI.
Strength --fgastrength 0 – 3.99, step 0.01 1 Factor on the analysed grain strength; 0 disables the grain. Only available with the two temporal analysis modes.
Decoded picture hash --decodedpicturehash off, md5, crc, checksum off Writes a hash of every decoded picture as SEI, so that a decoder can verify its output.
Minimize command line – on/off on Leaves out every option that equals the encoder's own default. The call gets shorter and the result is the same; off writes everything explicitly.
Custom addition any text empty Further vvencapp options, added to the call unchanged and unchecked. An --additional … entered here is merged into Hybrid's own, because the encoder only honours the last one.

The Configuration row below the tabs saves, loads and deletes named sets of all VVenC settings.

Example

Quantizer 20, refresh type idr, intra period 250 frames on a 10-bit YUV 4:2:0 source (640x352, 25 fps), with Minimize command line on:

vspipe "encodingTempSynthSkript.vpy" - --outputindex 0 -c y4m --progress | vvenc --input - --size 640x352 --y4m 1 --framerate 25 --framescale 1 --qp 20 --range limited --refreshtype idr --intraperiod 250 --additional MatrixCoefficients=smpte170m --output "video.vvc"

For a Matroska output the raw stream is then wrapped twice before the normal muxing:

ffmpeg -y -i "video_vvc.mp4" -map 0:v -c copy "video_vvc.mkv"

How Hybrid calls it

  • The filter script (Vapoursynth or AviSynth) is piped into vvencapp as y4m; without a script ffmpeg decodes the source and pipes it. Size and frame rate are passed as well (--size, --framerate, --framescale).
  • Color primaries, transfer, matrix, chroma location, HDR metadata, pixel aspect ratio and an --additional from Custom addition are collected into a single --additional, joined by colons.
  • With Minimize command line on these are left out when they equal the default: --preset medium, --qpa 1, --profile auto, --level auto, --tier main, --mtprofile -1, --ifp -1, --refreshtype cra, --refreshsec 1, --internal-bitdepth 10, --bitrate 0 (quantizer mode), --maxrate 0 and --fgastrength 1.
  • The bit rate modes write --passes 1 or --passes 2 --pass 1 / --pass 2 and the bit rate as --bitrate Nk. In 2-pass mode Hybrid creates one job per pass; the first pass only writes the statistics file.
  • vvencapp writes a raw stream (.vvc). For MP4 it is muxed with MP4Box, for TS/M2TS with tsMuxeR. For Matroska Hybrid first wraps it into MP4 with MP4Box, remuxes that to Matroska with ffmpeg and hands the result to the normal Matroska muxing; the intermediate files are removed afterwards.
  • A manually chosen level is checked against bit rate and frame rate when the job is created; Hybrid then names the next level that fits.

Background

Constant quality

VVenC has no CRF option. The equivalent is the quantizer mode with Adaptive quantization on: the QP sets the quality level and the perceptual model distributes it inside each picture. Adding a fixed Max rate limits the bit rate peaks of such an encode.

HDR

Signalling PQ or HLG through the color fields alone would leave the encoder in SDR mode. That is why Hybrid adds --hdr for these two transfer functions and still writes the single color values, which override the presets of --hdr one by one.

Sources