After some research, I achieved the video encoding with hw accelerate with gstreamer, both h264 and h265 codecs. For this, you have to use mpph264enc/mpph265enc options (h264/h265) , and also gstreamer1.0-rockchip. There are the full installation steps:
- For 3d hw drivers:
sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa
sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia
sudo apt update
sudo apt dist-upgrade
sudo apt install mali-g610-firmware rockchip-multimedia-config
- Install gstreamer and some plugins:
sudo apt install gstreamer1.0-rockchip
sudo apt install gstreamer1.0-plugins-base-apps
sudo apt install gstreamer1.0-plugins-bad
sudo apt install gstreamer1.0-plugins-good
- Use gstreamer, in this case getting the video from an usb webcam
# for h264
gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec ! mpph264enc ! h264parse ! mp4mux ! filesink location=test_h264.mp4 -e
# for h265
gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=640,height=480,framerate=30/1 ! jpegdec ! mpph265enc ! h265parse ! mp4mux ! filesink location=test_h265.mp4 -e
I'm still getting used to gstreamer, so any advice about the usability is welcome, and also I will update this post if I found any improvement