Gstreamer video encoding limited to 30fps on VIM3L

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu

Which version of system do you use? Please provide the version of the system here:

$ uname -a
Linux Khadas 5.15.137 #1.7.5 SMP PREEMPT Thu Sep 25 22:27:48 CST 2025 aarch64 aarch64 aarch64 GNU/Linux

$ cat /etc/fenix-release
# PLEASE DO NOT EDIT THIS FILE
BOARD=VIM3L
VENDOR=Amlogic
VERSION=1.7.5
ARCH=arm64
INITRD_ARCH=arm64
INSTALL_TYPE=EMMC
IMAGE_VERSION=1.7.5-250925
################ GIT VERSION ################
UBOOT_GIT_VERSION=khadas-vims-u-boot-2015.01-5.15-v1.7.5-release
LINUX_GIT_VERSION=khadas-vims-linux-5.15-v1.7.5-release
FENIX_GIT_VERSION=v1.7.5
#############################################

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

$ apt info gstreamer-aml
Package: gstreamer-aml
Version: 0.6-202406
Priority: optional
Section: kernel
Maintainer: Khadas <hello@khadas.com>
Installed-Size: 1,024 B
Depends: libion, libge2d, libmultienc | libamvenc, gst-aml-drmbufferpool-plugins
Download-Size: 603 kB
APT-Manual-Installed: yes
APT-Sources: http://dl.khadas.com/repos/vim3l noble/main arm64 Packages
Description: gstreamer-aml.

Please describe your issue below:

I’m unable to use a gstreamer pipeline to encode a 60fps live source because the amlvenc element is limiting the framerate to max 30fps even though the hardware encoder supports 60fps.

The specs for the VIM3L state it supports H.264/H.265 1080P@60fps hardware encoding. Following the instructions for H.265 encoding here VIM4 Hardware Encoding [Khadas Docs] I’m able to use the amvenc_test tool to encode an NV12 test file at average framerate of 73fps:

$ amvenc_test test.nv12 dump3.h265 1920 1080 60 60 6000000 100 1 0 2 5
src_url is      : test.nv12 ;
out_url is      : dump3.h265 ;
width   is      : 1920 ;
height  is      : 1080 ;
gop     is      : 60 ;
frmrate is      : 60 ;
bitrate is      : 6000000 ;
frm_num is      : 100 ;
fmt     is      : 1 ;
buf_type is     : 0 ;
num_planes is   : 2 ;
codec is        : 5 ;
codec is H265
Set log level to 1
[selectHW:105] selectEncoder
[selectHW:134] amvenc_265 present
[amvenc_265_load_Module:40] amvenc_ports w420 initModule!
Set log level to 4
25.5: rbsp_stop_one_bit: 1
25.4: rbsp_alignment_zero_bit: 0
25.3: rbsp_alignment_zero_bit: 0
25.2: rbsp_alignment_zero_bit: 0
25.1: rbsp_alignment_zero_bit: 0
[Total time: 1799497 us], [IO time: 429750 us]
[Encode Total time: 1369747 us], [avgTime: 13697 us], [avgfps: 73]
[amvenc_265_unload_Module:369] Unloading encoder api lib

However when I try to use the amlvenc gstreamer element to encode a 60fps live source, it drops frames resulting in a ~30fps capture. And if I try to set the framerate property explicitly to 60, it’s rejected because the element defines the maximum to be 30:

$ gst-inspect-1.0 amlvenc
...

  framerate           : framerate(fps)
                        flags: readable, writable
                        Integer. Range: 0 - 30 Default: 30


$ gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,format=NV12,width=1920,height=1080,framerate=60/1 ! amlvenc bitrate=6000 framerate=60 ! h265parse ! filesink location=test.h265

(gst-launch-1.0:3856): GLib-GObject-CRITICAL **: 17:12:26.942: value "60" of type 'gint' is invalid or out of range for property 'framerate' of type 'gint'

How can I get the gstreamer pipeline to encode at the full speed/framerate that the hardware supports?

Post a console log of your issue below:


2026-07-24T15:21:22.042Z Khadas I recordings_metrics Recordings metrics: video dropped buffers: 243, video dropped duration in ms: 5533, audio dropped buffers: 0, audio dropped duration in ms: 0, recording duration in s: 10

Hello @smthsm

I checked 1.7.5-250925 on my side, the fps can reach to 60.

Record:

gst-launch-1.0 -e videotestsrc is-live=true num-buffers=300 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=60/1 ! amlvenc bitrate=6000 framerate=60 ! h265parse ! qtmux !  filesink location=test.mp4

Check the video info:

root@Khadas:~# mediainfo test.mp4 
General
Complete name                            : test.mp4
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   2005.03 (qt  )
File size                                : 7.21 MiB
Duration                                 : 5 s 0 ms
Overall bit rate                         : 12.1 Mb/s
Frame rate                               : 60.000 FPS
Encoded date                             : 2026-07-28 01:36:50 UTC
Tagged date                              : 2026-07-28 01:37:00 UTC

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 5 s 0 ms
Bit rate                                 : 12.1 Mb/s
Maximum bit rate                         : 6 000 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.097
Stream size                              : 7.20 MiB (100%)
Encoded date                             : 2026-07-28 01:36:50 UTC
Tagged date                              : 2026-07-28 01:37:00 UTC
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : hvcC

Hey @numbqq - thanks for the help.

I tracked the issue down on my side to format negotiation picking RGB by default, despite my real live source (v4l2src USB camera) producing UYVY and the encoder seemingly wanting a YUV format (but not exactly UYVY). The full pipeline is more like this (ignoring the audio branch):

gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=120 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1 ! queue ! videoconvert ! queue ! amlvenc ! h265parse ! mp4mux ! filesink location=capture.mp4

So the camera was producing UYVY, videoconvert was converting it to RGB and then amlvenc was seemingly converting it back to NV12(?) before feeding it into the VPU.

I can get it to reliably hit 60fps by forcing the conversion to I420 as the intermediate format instead of RGB:

gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=120 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1 ! queue ! videoconvert ! video/x-raw,format=I420 ! queue ! amlvenc ! h265parse ! mp4mux ! filesink location=capture.mp4

The only remaining issue I’m having now is that because the encoder thinks it’s encoding at 30fps (because the framerate property maxes out at 30), it’s miscalculating the per-frame budget resulting in it overshooting its bitrate target by almost 2x:

# target bitrate=4000

$ gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=600 ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1 ! queue ! videoconvert ! video/x-raw,format=I420 ! queue ! amlvenc bitrate=4000 ! h265parse ! mp4mux ! filesink location=capture.mp4

# actual = 7623 kb/s

$ mediainfo capture.mp4
General
Complete name                            : capture.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41/isom/iso2)
File size                                : 9.35 MiB
Duration                                 : 10 s 286 ms
Overall bit rate                         : 7 627 kb/s
Frame rate                               : 58.334 FPS
Encoded date                             : 2026-07-30 19:00:10 UTC
Tagged date                              : 2026-07-30 19:00:21 UTC

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 10 s 286 ms
Bit rate                                 : 7 623 kb/s
Maximum bit rate                         : 4 000 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 58.334 FPS
Minimum frame rate                       : 3.133 FPS
Maximum frame rate                       : 375.000 FPS
Color space                              : YUV
Bits/(Pixel*Frame)                       : 0.063
Stream size                              : 9.35 MiB (100%)
Encoded date                             : 2026-07-30 19:00:10 UTC
Tagged date                              : 2026-07-30 19:00:21 UTC
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : hvcC