Aurora4 Sample Encoder

Introduction to the aurora4_sample_encoder

aurora4_sample_encoder is a simple encoder program demonstrating the use of the Aurora4 API.

The usage of aurora4_sample_encoder is shown as below:

Usage: ./aurora4_sample_encoder <preset> <tune> <width> <height> <depth> <fps-num> <in-yuv> <outfile> <keyframe-interval> <rc-type> <target-bitrate/crf/qp/quality> <threads> <frames to encode> [wz4-params] [debug-log]

preset: ultrafast superfast veryfast faster fast medium slow slower veryslow superslow
tune: default psnr ssim vmaf screen movie game zerolatency universe film grain animation stillimage arm fastdecode mpass

You can find more details listed as below for each parameter

  preset            <string>     ..... Set preset (supported presets listed in aurora4enc.h) parameter    
  tune              <string>     ..... Set tune(default psnr ssim vmaf screen movie game zerolatency universe film grain animation stillimage arm fastdecode mpass) parameter
  width             <int>        ..... Set frame width
  height            <int>        ..... Set frame height
  fps-num           <int>        ..... Set frame per seconds (from 1 to 120)
  in-yuv            <string>     ..... Set path of encoding sequence (only yuv is supported)
  outfile           <string>     ..... Set path of output file
  keyframe-interval <int>        ..... Set maximum keyframe intervals
  rc-type           <int>        ..... Set rate control type(-1:quality, 0: cqp, 1: crf, 2: abr) parameter
  target-bitrate/crf/qp/quality  <float>
                                 ..... Set target-bitrate(kbps) or crf values(from 1 to 51) or qp values(from 1 to 51) or quality (from 1 to 5)
  threads           <int>        ..... Set threads
  frames to encode  <int>        ..... Set frames to be encoded (from -1 to int_MAX, -1 means maximal availabe frames)
  wz264-params      <string>     ..... Set extra configurations (use ":" to separate different params)
  debug-log         <int>        ..... Set whether output debug logs or not (1: enable, 0: disable, default is 0), can be skipped

The executable is build from the file aurora4_sample_encoder.c and header files declaring the API functions and the relevant structures.

  • The encoder is built from wz4_enc_cfg_t which exposes the core parameters needed to set up the encoder.
  • Parameters can be modified before each encode call by updating the configuration, but this may cause the encoder to be reset in some cases.
  • A list of all the parameters that can be passed using the configuration string wz4_enc_cfg_t and wz264-params can be found here.
  • Further explanations for -preset and -tune in the table above are provided in the Presets and Tuning Options

Building the aurora4_sample_encoder

Step 1: The encoding configuration can be modified as per your requirements and for all possible options, please refer to samples/aurora4_sample_encoder.c. For example, parameters such as vbv_max_bitrate, vbv_buffer_size etc. can be reset according to your requirements.

Step 2: Build your own sample encoder by running the following -

Build: gcc samples/aurora4_sample_encoder.c -I include/ -L lib/ -laurora4 -o aurora4_sample_encoder

Run: LD_LIBRARY_PATH=`pwd`/lib/ ./aurora4_sample_encoder ...

Running the aurora4_sample_encoder

Here are some examples of running the aurora4_sample_encoder in different rate-control modes.

  • Constant quality mode is more suitable for on-demand application scenarios.
LD_LIBRARY_PATH=`pwd`/lib/ ./bin/aurora4_sample_encoder slow default 1920 1080 8 30 input.yuv output.264 300 1 30 4 1000 
  • Averaged bitrate mode is more suitable for live broadcast application scenarios.
LD_LIBRARY_PATH=`pwd`/lib/ ./bin/aurora4_sample_encoder fast default 1920 1080 8 30 input.yuv output.264 90 2 3000 8 1000 bframes=7:rc-lookahead=16 0
  • Constant bitrate mode is more suitable for RTC application scenarios.
LD_LIBRARY_PATH=`pwd`/lib/ ./bin/aurora4_sample_encoder veryfast zerolatency 1920 1080 8 30 input.yuv output.264 1000 3 2000 4 1000