-
Notifications
You must be signed in to change notification settings - Fork 75
Filter
Nyanmisaka edited this page Oct 16, 2024
·
14 revisions
The pixel formats, resolutions, AFBC, pixels/cycle, scaling ratio, etc. supported by RGA filter depend on the specific chip capabilities. RGA2 or newer hardware is required by this project. This chapter uses RK3588 (RGA2-Enhance/RGA3) for demonstration.
There are three available RGA filters.
-
scale_rkrga
: for the very common use - scaling and pixel format conversion. -
vpp_rkrga
: combinescale_rkrga
with extra cropping and transposing features. -
overlay_rkrga
: blending one image onto another image. A common use is to overlay watermarks or subtitles.
... overlay_rkrga VV->V Rockchip RGA (2D Raster Graphic Acceleration) video compositor
... scale_rkrga V->V Rockchip RGA (2D Raster Graphic Acceleration) video resizer and format converter
... vpp_rkrga V->V Rockchip RGA (2D Raster Graphic Acceleration) video post-process (scale/crop/transpose)
- Query RGA filters
./ffmpeg -hide_banner -filters | grep rkrga
- Query filter options by name
./ffmpeg -hide_banner -h filter=scale_rkrga
Filter scale_rkrga
Rockchip RGA (2D Raster Graphic Acceleration) video resizer and format converter
Inputs:
#0: default (video)
Outputs:
#0: default (video)
rgascale AVOptions:
w <string> ..FV....... Output video width (default "iw")
h <string> ..FV....... Output video height (default "ih")
format <pix_fmt> ..FV....... Output video pixel format (default none)
force_original_aspect_ratio <int> ..FV....... Decrease or increase w/h if necessary to keep the original AR (from 0 to 2) (default decrease)
disable 0 ..FV.......
decrease 1 ..FV.......
increase 2 ..FV.......
force_divisible_by <int> ..FV....... Enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used (from 1 to 256) (default 2)
force_yuv <int> ..FV....... Enforce planar YUV format output (from 0 to 3) (default disable)
disable 0 ..FV.......
auto 1 ..FV....... Match in/out bit depth
8bit 2 ..FV....... 8-bit
10bit 3 ..FV....... 10-bit uncompact/8-bit
force_chroma <int> ..FV....... Enforce chroma of planar YUV format output (from 0 to 4) (default auto)
auto 0 ..FV....... Match in/out chroma
420sp 1 ..FV....... 4:2:0 semi-planar
420p 2 ..FV....... 4:2:0 fully-planar
422sp 3 ..FV....... 4:2:2 semi-planar
422p 4 ..FV....... 4:2:2 fully-planar
core <flags> ..FV....... Set multicore RGA scheduler core [use with caution] (default 0)
default ..FV.......
rga3_core0 ..FV.......
rga3_core1 ..FV.......
rga2_core0 ..FV.......
rga2_core1 ..FV.......
async_depth <int> ..FV....... Set the internal parallelization depth (from 0 to 4) (default 2)
afbc <boolean> ..FV....... Enable AFBC (Arm Frame Buffer Compression) to save bandwidth (default false)
./ffmpeg -hide_banner -h filter=vpp_rkrga
Filter vpp_rkrga
Rockchip RGA (2D Raster Graphic Acceleration) video post-process (scale/crop/transpose)
Inputs:
#0: default (video)
Outputs:
#0: default (video)
rgavpp AVOptions:
w <string> ..FV....... Output video width (default "cw")
h <string> ..FV....... Output video height (default "w*ch/cw")
cw <string> ..FV....... Set the width crop area expression (default "iw")
ch <string> ..FV....... Set the height crop area expression (default "ih")
cx <string> ..FV....... Set the x crop area expression (default "(in_w-out_w)/2")
cy <string> ..FV....... Set the y crop area expression (default "(in_h-out_h)/2")
format <pix_fmt> ..FV....... Output video pixel format (default none)
transpose <int> ..FV....... Set transpose direction (from -1 to 6) (default -1)
cclock_hflip 0 ..FV....... Rotate counter-clockwise with horizontal flip
clock 1 ..FV....... Rotate clockwise
cclock 2 ..FV....... Rotate counter-clockwise
clock_hflip 3 ..FV....... Rotate clockwise with horizontal flip
reversal 4 ..FV....... Rotate by half-turn
hflip 5 ..FV....... Flip horizontally
vflip 6 ..FV....... Flip vertically
force_yuv <int> ..FV....... Enforce planar YUV format output (from 0 to 3) (default disable)
disable 0 ..FV.......
auto 1 ..FV....... Match in/out bit depth
8bit 2 ..FV....... 8-bit
10bit 3 ..FV....... 10-bit uncompact/8-bit
force_chroma <int> ..FV....... Enforce chroma of planar YUV format output (from 0 to 4) (default auto)
auto 0 ..FV....... Match in/out chroma
420sp 1 ..FV....... 4:2:0 semi-planar
420p 2 ..FV....... 4:2:0 fully-planar
422sp 3 ..FV....... 4:2:2 semi-planar
422p 4 ..FV....... 4:2:2 fully-planar
core <flags> ..FV....... Set multicore RGA scheduler core [use with caution] (default 0)
default ..FV.......
rga3_core0 ..FV.......
rga3_core1 ..FV.......
rga2_core0 ..FV.......
rga2_core1 ..FV.......
async_depth <int> ..FV....... Set the internal parallelization depth (from 0 to 4) (default 2)
afbc <boolean> ..FV....... Enable AFBC (Arm Frame Buffer Compression) to save bandwidth (default false)
./ffmpeg -hide_banner -h filter=overlay_rkrga
Filter overlay_rkrga
Rockchip RGA (2D Raster Graphic Acceleration) video compositor
Inputs:
#0: main (video)
#1: overlay (video)
Outputs:
#0: default (video)
rgaoverlay AVOptions:
x <string> ..FV....... Overlay x position (default "0")
y <string> ..FV....... Overlay y position (default "0")
alpha <int> ..FV....... Overlay global alpha (from 0 to 255) (default 255)
format <pix_fmt> ..FV....... Output video pixel format (default none)
eof_action <int> ..FV....... Action to take when encountering EOF from secondary input (from 0 to 2) (default repeat)
repeat 0 ..FV....... Repeat the previous frame.
endall 1 ..FV....... End both streams.
pass 2 ..FV....... Pass through the main input.
shortest <boolean> ..FV....... Force termination when the shortest input terminates (default false)
repeatlast <boolean> ..FV....... Repeat overlay of the last overlay frame (default true)
core <flags> ..FV....... Set multicore RGA scheduler core [use with caution] (default 0)
default ..FV.......
rga3_core0 ..FV.......
rga3_core1 ..FV.......
rga2_core0 ..FV.......
rga2_core1 ..FV.......
async_depth <int> ..FV....... Set the internal parallelization depth (from 0 to 4) (default 2)
afbc <boolean> ..FV....... Enable AFBC (Arm Frame Buffer Compression) to save bandwidth (default false)
-
scale_rkrga
(1080p -> 720p)
./ffmpeg -init_hw_device rkmpp=hw -filter_hw_device hw -f lavfi -i testsrc2=s=1920x1080,format=nv12 \
-vf hwupload,scale_rkrga=w=1280:h=720:format=nv12 -c:v h264_rkmpp -b:v 4M -maxrate 4M -vframes 1000 -y /tmp/tmp.mp4
-
vpp_rkrga
transposing (1080p landscape -> 720p, 90 degrees clockwise rotated)
./ffmpeg -init_hw_device rkmpp=hw -filter_hw_device hw -f lavfi -i testsrc2=s=1920x1080,format=nv12 \
-vf hwupload,vpp_rkrga=w=1280:h=720:format=nv12:transpose=clock -c:v h264_rkmpp -b:v 4M -maxrate 4M -vframes 1000 -y /tmp/tmp.mp4
-
vpp_rkrga
cropping (1080p -> selecting lower right quarter 540p region and upscaling to 720p)
./ffmpeg -init_hw_device rkmpp=hw -filter_hw_device hw -f lavfi -i testsrc2=s=1920x1080,format=nv12 \
-vf hwupload,vpp_rkrga=cx=960:cy=540:cw=960:ch=540:w=1280:h=720:format=nv12 -c:v h264_rkmpp -b:v 4M -maxrate 4M -vframes 1000 -y /tmp/tmp.mp4
-
overlay_rkrga
(Put the 540p image on top of 1080p image and center it. The main image can be YUV or RGB, overlay image MUST be RGB)
./ffmpeg -init_hw_device rkmpp=hw -filter_hw_device hw -f lavfi -i color=c=cyan:s=1920x1080,format=nv12 -f lavfi -i testsrc2=s=960x540,format=bgra \
-filter_complex "[0:v]hwupload[main];[1:v]hwupload[overlay];[main][overlay]overlay_rkrga=eof_action=pass:repeatlast=0:format=nv12:x=(W-w)/2:y=(H-h)/2" \
-c:v h264_rkmpp -b:v 4M -maxrate 4M -vframes 1000 -y /tmp/tmp.mp4