Skip to main content
Version: v5.9.0

ni_quadra_drawbox

The ni_quadra_drawbox filter can draw multiple same coloured boxes on a picture/video. It works just like the FFmpeg software drawbox filter but uses the hardware to do the drawing. Quadra does not support the FFmpeg drawbox AVOptions of thickness or replace. It can only draw with two pixel thickness.

ni_quadra_drawbox only supports hardware AVFrames as input and output. To draw a software frame, use ni_quadra_hwupload to upload the frame to the Quadra device. If the hardware frame is on the same device as the scaler, it can be accessed directly.

note

The ni_quadra_drawbox filter only supports limited color range video (also known as “TV” range). While full range (or “PC” range) video is accepted by the filter, the ni_quadra_drawbox filter will clamp to limited color range video before processing. This clamp will cause a slight color shift in the output video.

Because of HW limitations, there is chromatic aberration when box y position is even value. This should be avoided when drawing boxes.

Parameters​

The following are the ni_quadra_drawbox parameters:

x / y​

The expressions which specify the top left corner coordinates of the box.

Default0

width, w​

height, h

The expressions which specify the width and height of the box.

Default0

color, c​

Specify the color of the box to write.

Defaultblack

x1 y1 w1 h1​

Those expressions are the same as x y w and h, but for box 1.

x2 y2 w2 h2​

Those expressions are the same as x y w and h, but for box 2.

x3 y3 w3 h3​

Those expressions are the same as x y w and h, but for box 3.

x4 y4 w4 h4​

Those expressions are the same as x y w and h, but for box 4.

is_p2p​

Specifies if output buffer of the filter is p2p buffer. When is_p2p is set to 1, the output buffer of the filter is set as p2p buffer and can be read out by p2p read. Else the output buffer is normal and cannot perform p2p.

Supported ValuesBool 0 and 1
Default0

inplace​

Specifies if the drawing of the box should be done in-place. Using this parameter will improve performance at the cost of violating FFmpeg convention. Normally, the Quadra hardware copies the input frame and creates a copy of the frame with the draw boxes applied. With this parameter, the input frame is modified to reduce hardware memory bandwidth. Do not use the split or ni_quadra_split filter before the ni_quadra_drawbox in the filter graph otherwise other filters after the split will be affected.

The following example shows how to use drawbox. The decoder decodes a H.264 input using the h264_ni_quadra_dec, ni_quadra_scale converts yuv420p to rgba, ni_quadra_drawbox draws a red box at x=100, y=100, w=1720, h=880 and ni_quadra_scale converts rgba to yuv420p before passing it to h264_ni_quadra_enc for encoding.

ffmpeg -vsync 0 -c:v h264_ni_quadra_dec -xcoder-params 'out=hw' -i input.h264 -vf ' ni_quadra_scale=iw:ih:format=rgba,ni_quadra_drawbox=x=100:y=100:h=1720:w=880:c=red:x1=200:y1=100:w1=300:h1=200,ni_quadra_scale=iw:ih:format=yuv420p ' -c:v h264_ni_quadra_enc -c:a copy output.h264