XMA Examples for the Xilinx Video SDK

The examples in the examples/xma folder illustrate how C-based applications can natively interact with Xilinx devices using the Xilinx Video SDK plugins and the XMA (Xilinx Media Accelerator) APIs. The examples are for advanced use-cases where using the FFmpeg command-line interface is not appropriate.

Detailed documentation on the Xilinx Video SDK plugin interface and the XMA APIs can be found in the C API Programming Guide section of the documentation.

Requirements

  • The XMA applications has been built for and verified on Ubuntu 18.04, Ubuntu 20.04, RHEL 7.8 and AWS Linux V2.

  • The XMA applications only work with elementary streams. Container formats such as mp4 are not supported.

Build Instructions

Pre-requisites

To build and test the XMA applications, the Xilinx Video SDK packages must be installed on the server, and the Xilinx devices must to be flashed with the shell provided in the release package.

Build

  1. Export the XRT and XRM to build the xma apps:

    source /opt/xilinx/xcdr/setup.sh
    
  2. Do make clean and make dev in the application directory:

    cd examples/xma
    make clean
    make dev
    

    The executables are placed in the Debug/xma_apps/examples directory.

  3. Optional: to generate DEB and RPM packages for the XMA apps, run one of the two commands below:

    make DEB
    make RPM
    

Test

The build_and_test.bash script included in the ./examples/xma directory can be used to build and test all the XMA applications at once. This script sets up the environment, builds all the applications and then runs a simple test to validate that each of the applications works correctly. Run the script as follows:

./build_and_test.bash

To test each application individually, refer to the sections below.


XMA Decoder App

Decoder Test Instructions

The XMA decoder application supports most of the decode options supported by FFmpeg. The XMA decoder application supports only elementary H.264 or HEVC encoded bitstream and outputs YUV.

Decoder Usage

Before running decoding application, source the xcdr environment:

source /opt/xilinx/xcdr/setup.sh

Running the decoder app with the --help option will print the complete list of options:

u30_xma_decode --help
This is a standalone xma decoder app. It ingests an h264 or h265
encoded file and utilizes hardware acceleration to get the decoded
output.

Usage: 
	./u30_xma_decode [options] -i <input-file> -c:v <codec-type> 
	[codec_options] -o <output-file>

Arguments:
	--help                     Print this message and exit
	-log <level>               Specify the log level
	-d <device-id>             Specify a device on which to run.
	                           Default: 0

Input Arguments:

	-stream_loop <loop-count>  Number of times to loop the input
	                           file
	-i <input-file>            Input file to be used

Codec Arguments:

	-c:v <codec>               Specify H264 or H265 decoding. 
	                           (mpsoc_vcu_h264, mpsoc_vcu_hevc)
	-low_latency               Should low latency decoding be used.
	-entropy_buf_cnt <count>   Specify number of internal entropy
	                           buffers. [2-10], default: 2
	-latency_logging           Log latency information to syslog
	-splitbuff_mode            Configure decoder in split/unsplit
	                           input buffer mode.
	-frames <frame-count>      Number of frames to be processed.
	-pix_fmt fmt               The output format (nv12, yuv420p, 
	                           yuv420p10le, xv15) Default: nv12 for 8-bit, 
	                           yuv420p10le for 10-bit.
	-o <file>                  File to which output is written.

Sample Decoder Command

Decode an h264 encoded file:

u30_xma_decode  -i ~/CSGO_1920x1080_5000kbps.264 -c:v mpsoc_vcu_h264 -o ./CSGO_1920x1080.NV12

For more examples, refer to the examples/xma/decoder/test/scripts/decoder_app_test.sh script.

examples/xma/include/decoder.rst


XMA Encoder App

Encoder Test Instructions

The encoder XMA application supports most of the encoder options supported by FFmpeg. The XMA application supports only YUV 4:2:0 input and outputs H.264/HEVC encoded elementary stream.

Encoder Usage

Before running encoder application, source the xcdr environment:

source /opt/xilinx/xcdr/setup.sh

Running the encoder app with the -help option will print the complete list of options:

u30_xma_encode -help
 XMA Encoder App Usage:
    ./program [input options] -i input-file -c:v <codec-option>  [encoder options] -o <output-file>

Arguments:

    --help                     Print this message and exit.
    -d <device-id>             Specify a device on which the encoder
                                to run. Default: 0
    -frames <frame-count>      Number of frames to be processed.

Input options:

    -stream_loop <loop-count>  Number of times to loop the input YUV
                                file.
    -w <width>                 Width of YUV input.
    -h <height>                Height of YUV input.
    -pix_fmt <pixel-format>    Pix format of the input file (yuv420p,
                                nv12, yuv420p10le, xv15). Default: nv12
    -i <input-file>            Name and path of input YUV file

Codec option:
    -c:v <codec>               Encoder codec to be used. Supported
                                are mpsoc_vcu_hevc, mpsoc_vcu_h264
Encoder params:
    -b:v <bitrate>             Bitrate can be given in Kbps or Mbps
                                or bits i.e., 5000000, 5000K, 5M.
                                Default is 200kbps
    -fps <fps>                 Input frame rate. Default is 25.
    -g <intraperiod>           Intra period. Default is 12.
    -control-rate <mode>       Rate control mode. Supported are 0
                                to 3, default is 1.
    -max-bitrate <bitrate>     Maximum bit rate. Supported are 0 to
                                350000000, default is 5000
    -slice-qp <qp>             Slice QP. Supported are -1 to 51,
                                default is -1
    -min-qp <qp>               Minimum QP. Supported are 0 to 51,
                                default is 0.
    -max-qp <qp>               Maximum QP. Supported values are 0
                                to 51, default is 51.
    -bf <frames>               Number of B frames. Supported are 0
                                to INT_MAX, default is 2.
                                For GOP mode 0, supported are 0 to 4
                                For GOP mode 1, supported 3, 5, 7, 15
                                For GOP mode 2, no B frames.
                                For GOP mode 3, supported are 0 to INT_MAX
    -periodicity-idr <value>   IDR picture frequency. Supported are
                                0 to UINT32_MAX, default is
                                UINT32_MAX.
    -force_key_frame <value>   Insert idr frame dynamically (Frame
                                numbers starting from 0)
                                Example: -force_key_frame "(122,222,333)"
    -profile <value>           Encoder profile.
                For HEVC, supported are 0 or main, 1 or main-intra,
                                2 or main-10 and 3 or main-10-intra.
                                Default is 0/main.
                                ENC_HEVC_MAIN - 0 or main.
                                ENC_HEVC_MAIN_INTRA - 1 or main-intra.
                                ENC_HEVC_MAIN_10 - 2 or main-10.
                                ENC_HEVC_MAIN_10_INTRA - 3 or main-10-intra.
                For H264, supported are 66 or baseline, 77 or main,
                                100 or high, 110 or high-10 and
                                2158 or high-10-intra. Default is 100
                                ENC_H264_BASELINE - 66 or baseline.
                                ENC_H264_MAIN - 77 or main.
                                ENC_H264_HIGH - 100 or high.
                                ENC_H264_HIGH_10 - 110 or high-10.
                                ENC_H264_HIGH_10_INTRA - 2158 or high-10-intra.
    -level <value>             Encoder level.
                                For HEVC, supported are 10, 11, 20,
                                21, 30, 31, 40, 41, 50, 51.
                                default is 10.
                                For H264, supported are 10, 11, 12,
                                13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 
                                50, 51, 52. Default is 10.
    -slices <value>            Number of slices per frame. Supported
                                are 1 to 68, default is 1.
    -qp-mode <mode>            QP mode. Supported are 0, 1, and 2,
                                default is 1.
    -aspect-ratio <value>      Aspect ratio. Supported values are 0
                                to 3, default is 0.
    -scaling-list <0/1>        Scaling list. Enable/Disable,
                                default enable.
    -lookahead-depth <value>   Lookahead depth. Supported are 0 to
                                20, default is 0.
    -temporal-aq <0/1>         Temporal AQ. Enable/Disable,
                                default disable.
    -spatial-aq <0/1>          Spatial AQ. Enable/Disable,
                                default disable.
    -spatial-aq-gain <value>   Spatial AQ gain. Supported are 0 to
                                100, default is 50.
    -cores <value>             Number of cores to use, supported are
                                0 to 4, default is 0.
    -tune-metrics <0/1>        Tunes MPSoC H.264/HEVC encoder's video
                                quality for objective metrics, default
                                disable.
    -latency_logging <0/1>     Enable latency logging in syslog.
    -expert-options <string>   Expert options for the encoder, stored
                                as string of key=value pairs.
                                dynamic-params=<params_file>
    -o <file>                  File to which output is written.

Sample Encoder Commands

H.264 encoding, best objective score, low latency:

u30_xma_encode -w 1920 -h 1080  -i input_1080.yuv -c:v mpsoc_vcu_h264 -fps 60 -b:v 5000 -profile 2 -level 42 -g 120 -periodicity-idr 120 -qp-mode 0 -scaling-list 0 -bf 0 -o out1.264

H.264 encoding, best visual score, low latency:

u30_xma_encode -w 1920 -h 1080  -i input_1080.yuv -c:v mpsoc_vcu_h264 -fps 60 -b:v 5000 -profile 2 -level 42 -g 120 -periodicity-idr 120 -qp-mode 1 -bf 0 -o out2.264

H.264 encoding, using dynamic encoder paramters:

u30_xma_encode -w 1920 -h 1080 -pix_fmt yuv420p -i input_1080.yuv -fps 60 -g 120 -periodicity-idr 120 -frames 600 -c:v mpsoc_vcu_h264 -expert-options dynamic-params=cmdfile.txt -lookahead-depth 20 -spatial-aq 1 -temporal-aq 1 -spatial-aq-gain 80 -o out3.264

HEVC encoding, best visual score, low latency:

u30_xma_encode -w 1920 -h 1080  -i input_1080.yuv -c:v mpsoc_vcu_hevc -fps 60 -b:v 4000 -g 120 -periodicity-idr 120 -qp-mode 1 -bf 0 -o out1.265

HEVC encoding, best visual score, normal latency:

u30_xma_encode -w 1920 -h 1080  -i input_1080.yuv -c:v mpsoc_vcu_hevc -fps 60 -b:v 4000 -g 120 -periodicity-idr 120 -qp-mode 3 -bf 1 -lookahead-depth 20 -temporal-aq 1 -spatial-aq 1 -o out2.265

HEVC encoding, using dynamic encoder paramters:

u30_xma_encode -w 1920 -h 1080 -pix_fmt yuv420p -i input_1080.yuv -fps 60 -g 120 -periodicity-idr 120 -frames 600 -c:v mpsoc_vcu_hevc -expert-options dynamic-params=cmdfile.txt -lookahead-depth 20 -spatial-aq 1 -temporal-aq 1 -spatial-aq-gain 80 -o out3.265

For more examples, refer to the examples/xma/encoder/test/scripts/encoder_app_test.sh script.

Dynamic params config file format for the Encoder app

The config text file should have dynamic parameters for a frame on each line. It can have single parameter or multiple parameters for a frame on each line:

<frameNumberN1>:<key1>=<value1>
<frameNumberN2>:<key2>=<value2>,<key3>=<value3>

Keys allowed with their range of values

Dynamic Parameter

Key

Valid Values

Number of B frames

NumB=<int>

0 to 4

Bitrate (in bits per second)

BR=<int>

1K to INT_MAX

Temporal AQ mode

tAQ=<int>

0 to 1

Spatial AQ mode

sAQ=<int>

0 to 1

Spatial AQ gain

sAQGain=<int>

0 to 100

Sample dynamic params config file contents

300:NumB=1
600:BR=6000000
1200:sAQ=1,sAQGain=50
1800:tAQ=1
2400:NumB=0,BR=10000000,sAQ=0,sAQGain=50,tAQ=0

Limitations of the Encoder App

  • The encoder application supports only yuv 420 8-bit or 10-bit.

  • The application outputs only H264/HEVC elementary streams.

  • The application supports multi-process but not multi-channel.

  • The dynamic params config file has a restricted format. Please check above sample config file format.


XMA Scaler App

Scaler Test Instructions

The scaler XMA application supports most of the scaler options supported by FFmpeg. The XMA application supports only YUV 4:2:0 input and outputs YUV 4:2:0 scaled elementary stream.

Scaler Usage

Before running scaler application, source the xcdr environment:

source /opt/xilinx/xcdr/setup.sh

Below is the list of all the options of the scaler app:

This program ingests an nv12, yuv420p, yuv420p10le, or xv15 input
file and utilizes hardware acceleration to scale to various resolutions.

Usage:
    u30_xma_scale [options] -w <input-width> -h <input-height> -i
    <input-file> [scaler_options] -w <output-1-width> -h
    <output-1-height> -o <output-1-file> -w ...

Arguments:
    --help                     Print this message and exit
    -log <level>               Specify the log level
    -d <device-id>             Specify a device on which to run.
                                Default: 0

Input Arguments:

    -stream_loop <loop-count>  Number of times to loop the input
                                file
    -w <width>                 Specify the input's width
    -h <height>                Specify the input's height
    -pix_fmt <pixel-format>    Pixel format of the input file (nv12,
                                xv15, yuv420p10le). Default : nv12.
    -fps <frame-rate>          Frame rate. Used for scaler load
                                calculation.
    -i <input-file>            Input file to be used

Output Arguments:
    -coeff_load <load>         Specify the coefficient load. 0 Auto
                                (default), 1 static, 2 FilterCoef.txt.
    -enable_pipeline           Enable scaler pipeline. Default disabled (0)
    -rate <half/full>          Set the rate to half. Half rate drops
                                frames to reduce resource usage.
                                Default: full.
    -enable-latency-logging    Enable latency logging
    -w <width>                 Specify the output's width
    -h <height>                Specify the output's height
    -pix_fmt <pixel-format>    Pixel format of the output file (nv12,
                                xv15, yuv420p10le). Default: input fmt
    -frames <frame-count>      Number of frames to be processed.
    -o <file>                  File to which output is written.

Sample Scaler Command

Scale 1080p nv12 to 720p, 480p, 360p, and 240p nv12:

u30_xma_scale -w 1920 -h 1080 -i ~/Kimono1_1920x1080_24.yuvNV12 -w 1280 -h \
      720 -o Kimono_1280x720.NV12 -w 852 -h 480 -o Kimono_852x480.NV12 -w \
      640 -h 360 -o Kimono_640x360.NV12 -w 480 -h 240 -o Kimono_480x240.NV12

For more examples, refer to the examples/xma/scaler/test/scripts/scaler_app_test.sh script.

Limitations of the Scaler App

  • There may be a performance degradation relative to ffmpeg with a high number of outputs/processes.


XMA Transcoder App

Transcoder Test Instructions

The transcoder XMA application supports most of the options supported by ffmpeg. The XMA application supports only elementary H.264 and HEVC encoded stream input and outputs H.264/HEVC encoded elementary stream.

Transcoder Usage

Before running transcoder application, source the xcdr environment:

source /opt/xilinx/xcdr/setup.sh

Running the transcoder app with the --help option will print the complete list of options:

./u30_xma_transcode --help
XMA Transcoder App Usage:
    ./program [generic options] -c:v <decoder codec> [decoder options]  -i input-file -multiscale_xma -outputs [num] [Scaler options]  -c:v <encoder codec> [encoder options] -o <output-file>  -c:v <encoder codec> [encoder options] -o <output-file>  -c:v <encoder codec> [encoder options] -o <output-file>.....

Arguments:

    --help                     Print this message and exit.
    -d <device-id>             Specify a device on which the
                                transcoder to run. Default: 0
    -stream_loop <loop-count>  Number of times to loop the input file
    -frames <frame-count>      Number of input frames to be processed

Decoder options:

    -c:v <codec>               Decoder codec to be used. Supported
                                are mpsoc_vcu_hevc, mpsoc_vcu_h264
    -dl <device-id>            Specify device on which decoder should run
    -low-latency <0/1>         Low latency for decoder. Default
                                disabled
    -latency_logging <0/1>     Latency logging for decoder. Default
                                disabled
    -i <input-file>            Name and path of input H.264/HEVC file

Scaler options:

    -multiscale_xma            Name of the ABR scaler filter
    -num-output <value>        Number of output files from scaler
    -xvbm_convert              Convert the scaler's input into a host buffer.
                                Useful when running scaler on a different device.
    -dl <device-id>            Specify device on which scaler should run
    -enable_pipeline           Enable/disable pipelining in the scaler. Default disabled (0)
    -out_1_width <width>       Width of the scaler output channel 1
    -out_1_height <height>     Height of the scaler output channel 1
    -out_1_rate <full/half>    Full of Half rate for output channel 1
    -out_2_width <width>       Width of the scaler output channel 2
    -out_2_height <height>     Height of the scaler output channel 2
    -out_2_rate <full/half>    Full of Half rate for output channel 2
    -out_3_width <width>       Width of the scaler output channel 3
    -out_3_height <height>     Height of the scaler output channel 3
    -out_3_rate <full/half>    Full of Half rate for output channel 3
    -out_4_width <width>       Width of the scaler output channel 4
    -out_4_height <height>     Height of the scaler output channel 4
    -out_4_rate <full/half>    Full of Half rate for output channel 4
    -out_5_width <width>       Width of the scaler output channel 5
    -out_5_height <height>     Height of the scaler output channel 5
    -out_5_rate <full/half>    Full of Half rate for output channel 5
    -out_6_width <width>       Width of the scaler output channel 6
    -out_6_height <height>     Height of the scaler output channel 6
    -out_6_rate <full/half>    Full of Half rate for output channel 6
    -out_7_width <width>       Width of the scaler output channel 7
    -out_7_height <height>     Height of the scaler output channel 7
    -out_7_rate <full/half>    Full of Half rate for output channel 7
    -out_8_width <width>       Width of the scaler output channel 8
    -out_8_height <height>     Height of the scaler output channel 8
    -out_8_rate <full/half>    Full of Half rate for output channel 8
    -latency_logging <0/1>     Latency logging for scaler. Default
                                disabled
Encoder options:

    -c:v <codec>               Encoder codec to be used. Supported
                                are mpsoc_vcu_hevc, mpsoc_vcu_h264
    -dl <device-id>            Specify device on which encoder should run
    -b:v <bitrate>             Bitrate can be given in Kbps or Mbps
                                or bits i.e., 5000000, 5000K, 5M.
                                Default is 200kbps
    -fps <fps>                 Input frame rate. Default is 25.
    -g <intraperiod>           Intra period. Default is 12.
    -control-rate <mode>       Rate control mode. Supported are 0
                                to 3, default is 1.
    -max-bitrate <bitrate>     Maximum bit rate. Supported are 0 to
                                350000000, default is 5000
    -slice-qp <qp>             Slice QP. Supported are -1 to 51,
                                default is -1
    -min-qp <qp>               Minimum QP. Supported are 0 to 51,
                                default is 0.
    -max-qp <qp>               Maximum QP. Supported values are 0
                                to 51, default is 51.
    -bf <frames>               Number of B frames. Supported are 0
                                to INT_MAX, default is 2.
                                For GOP mode 0, supported are 0 to 4
                                For GOP mode 1, supported 3, 5, 7, 15
                                For GOP mode 2, no B frames.
                                For GOP mode 3, supported are 0 to INT_MAX
    -periodicity-idr <value>   IDR picture frequency. Supported are
                                0 to UINT32_MAX, default is
                                UINT32_MAX.
    -force_key_frame <value>   Insert idr frame dynamically  (Frame
                                numbers starting from 0)
                                Example: -force_key_frame "(122,222,333)"
    -profile <value>           Encoder profile.
                For HEVC, supported are 0 or main, 1 or main-intra,
                                2 or main-10 and 3 or main-10-intra.
                                Default is 0/main.
                                ENC_HEVC_MAIN - 0 or main.
                                ENC_HEVC_MAIN_INTRA - 1 or main-intra.
                                ENC_HEVC_MAIN_10 - 2 or main-10.
                                ENC_HEVC_MAIN_10_INTRA - 3 or main-10-intra.
                For H264, supported are 66 or baseline, 77 or main,
                                100 or high, 110 or high-10 and
                                2158 or high-10-intra. Default is 100
                                ENC_H264_BASELINE - 66 or baseline.
                                ENC_H264_MAIN - 77 or main.
                                ENC_H264_HIGH - 100 or high.
                                ENC_H264_HIGH_10 - 110 or high-10.
                                ENC_H264_HIGH_10_INTRA - 2158 or high-10-intra.
    -level <value>             Encoder level.
                                For HEVC, supported are 10, 11, 20,
                                21, 30, 31, 40, 41, 50, 51.
                                default is 10.
                                For H264, supported are 10, 11, 12,
                                13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52.
                                default is 10.
    -slices <value>            Number of slices per frame. Supported
                                are 1 to 68, default is 1.
    -qp-mode <mode>            QP mode. Supported are 0, 1, and 2,
                                default is 1.
    -aspect-ratio <value>      Aspect ratio. Supported values are 0
                                to 3, default is 0.
    -scaling-list <0/1>        Scaling list. Enable/Disable,
                                default enable.
    -lookahead-depth <value>   Lookahead depth. Supported are 0 to
                                20, default is 0.
    -temporal-aq <0/1>         Temporal AQ. Enable/Disable,
                                default disable.
    -spatial-aq <0/1>          Spatial AQ. Enable/Disable,
                                default disable.
    -spatial-aq-gain <value>   Spatial AQ gain. Supported are 0 to
                                100, default is 50.
    -cores <value>             Number of cores to use, supported are
                                0 to 4, default is 0.
    -tune-metrics <0/1>        Tunes MPSoC H.264/HEVC encoder's video
                                quality for objective metrics, default
                                disable.
    -latency_logging <0/1>     Enable latency logging in syslog.
    -expert-options <string>   Expert options for the encoder, stored as
                                string of key=value pairs.
                                dynamic-params=<params_file>
    -o <file>                  File to which output is written.

Sample Transcoder Commands

H.264 to HEVC ABR Transcoder:

u30_xma_transcode -c:v mpsoc_vcu_h264 -i input_1080p.264 -multiscale_xma -num-output 4 -out_1_width 1280 -out_1_height 720 -out_2_width 848 -out_2_height 480 -out_3_width 640 -out_3_height 360 -out_4_width 288 -out_4_height 160 \
-c:v mpsoc_vcu_hevc -b:v 4000K  -o out1_test1.265 -c:v mpsoc_vcu_hevc -b:v 3000K -o out1_test2.265 -c:v mpsoc_vcu_hevc -b:v 2500K -o out1_test3.265 -c:v mpsoc_vcu_hevc -b:v 1250K -o out1_test4.265 -c:v mpsoc_vcu_hevc -b:v 625K -o out1_test5.265

HEVC ABR Transcoder with Look-Ahead:

u30_xma_transcode -c:v mpsoc_vcu_hevc -i input_1080p.265 -multiscale_xma -num-output 4 -out_1_width 1280 -out_1_height 720 -out_2_width 848 -out_2_height 480 -out_3_width 640 -out_3_height 360 -out_4_width 288 -out_4_height 160 \
-c:v mpsoc_vcu_hevc -b:v 4000K -qp-mode 3 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_la_test1.265 -c:v mpsoc_vcu_hevc -b:v 3000K -qp-mode 3 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_la_test2.265 \
-c:v mpsoc_vcu_hevc -b:v 2500K -qp-mode 3 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_la_test3.265 -c:v mpsoc_vcu_hevc -b:v 1250K -qp-mode 3 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_la_test4.265 \
-c:v mpsoc_vcu_hevc -b:v 625K -qp-mode 3 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_la_test5.265

H.264 to HEVC ABR Transcoder with Scaler Pipeline:

u30_xma_transcode -c:v mpsoc_vcu_h264 -i input_1080p.264 -multiscale_xma -num-output 4 -out_1_width 1280 -out_1_height 720 -out_2_width 848 -out_2_height 480 -out_3_width 640 -out_3_height 360 -out_4_width 288 -out_4_height 160 \
-c:v mpsoc_vcu_hevc -b:v 4000K  -o out3_sc_test1.265 -c:v mpsoc_vcu_hevc -b:v 3000K -o out3_sc_test2.265 -c:v mpsoc_vcu_hevc -b:v 2500K -o out3_sc_test3.265 -c:v mpsoc_vcu_hevc -b:v 1250K -o out3_sc_test4.265 -c:v mpsoc_vcu_hevc -b:v 625K -o out3_sc_test5.265

H.264 ABR Transcoder with dynamic encoder parameters:

u30_xma_transcode -c:v mpsoc_vcu_h264 -i sample.h264 -multiscale_xma -num-output 2 -out_1_width 1280 -out_1_height 720 -out_2_width 848 \
-c:v mpsoc_vcu_h264 -b:v 4000K -expert-options dynamic-params=cmdfile.txt -qp-mode 2 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_dp_test1.h264 \
-c:v mpsoc_vcu_h264 -b:v 3000K -expert-options dynamic-params=cmdfile.txt -qp-mode 2 -lookahead-depth 16 -temporal-aq 1 -spatial-aq 1 -spatial-aq-gain 75 -o out_dp_test2.h264

For more examples, refer to the examples/xma/transcoder/test/scripts/transcoder_app_test.sh script.

Dynamic params config file format for the Transcoder app

The config text file should have dynamic parameters for a frame on each line. It can have single parameter or multiple parameters for a frame on each line:

<frameNumberN1>:<key1>=<value1>
<frameNumberN2>:<key2>=<value2>,<key3>=<value3>

Keys allowed with their range of values

Dynamic Parameter

Key

Valid Values

Number of B frames

NumB=<int>

0 to 4

Bitrate (in bits per second)

BR=<int>

1K to INT_MAX

Temporal AQ mode

tAQ=<int>

0 to 1

Spatial AQ mode

sAQ=<int>

0 to 1

Spatial AQ gain

sAQGain=<int>

0 to 100

Sample dynamic params config file contents

300:NumB=1
600:BR=6000000
1200:sAQ=1,sAQGain=50
1800:tAQ=1
2400:NumB=0,BR=10000000,sAQ=0,sAQGain=50,tAQ=0

Limitations of the Transcoder App

  • The transcoder application supports only elementary H264/HEVC encoded streams as input file. It cannot parse container formats like MP4, AVI, etc.

  • The transcoder outputs only H264/HEVC elementary streams.

  • The lookahead depth should be same for all the channels.

  • The dynamic params config file has a restricted format. Please check above sample config file format.