Jump to content

How I can use hardware-acceleration to encode/transcode video on Orange Pi 5 using FFmpeg? (or I need to use gstreamer?)


Recommended Posts

Posted

I searched & tried all materials I can find, trying to set up FFmpeg to work with hardware acceleration on Orange Pi 5.

But it did NOT work. 

Anyone else succeeds in using GPU hardware acceleration to encode/transcode video on Orange Pi 5 using FFmpeg? (or using gstreamer?)

Could you please share with me the way to do it?

 

Thank you very much indeed!

Posted

@MinhIt is not GPU hw acc but VPU you need.
Are you using the @amazingfate multimedia ppa?
 

sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa            #Panfork GPU ppa
sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia     #Multimedia ppa for VPU acceleration
sudo apt update
sudo apt dist-upgrade
sudo apt install mali-g610-firmware rockchip-multimedia-config

I suspect you might need gstreamer. That's included. My knowledge ain't great in these things, so maybe amazingfate or someone else can add to it.

Posted

@NicoD Thank you, I tried it before but it doesn't work. I also installed gstreamer:

# gst-launch-1.0 filesrc location=Screen_Recording.mp4 ! decodebin ! videoconvert ! omxh264enc ! video/x-h264, width=1280, height=720 ! mp4mux ! filesink location=output_hwaccel_omx.mp4 

WARNING: erroneous pipeline: no element "omxh264enc"

 

Posted (edited)

@amazingfate yeah it's just one option I tried. I tried many options for each hwaccels, encoders, decoders,... it doesn't work. 

Surprisingly, we don't have an good guide for an essentials task like this...

Edited by Minh
Posted (edited)

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

 

 

 

Edited by Simon Sepulveda
Posted (edited)

Thank @simaidensepul! Could you share with me the image/distro you're using?

Currently, I have 3 images:

  1. Armbian_23.5.1_Orangepi5_jammy_legacy_5.10.160_gnome_desktop.img (and Armbian_23.5.1_Orangepi5_jammy_legacy_5.10.160.img) 

  2. ubuntu-22.04.2-preinstalled-server-arm64-orangepi5.img

  3. Orangepi5_1.1.4_ubuntu_jammy_server_linux5.10.110.img

Thank you very much! 

Edited by Minh
Posted

Hi, have you solved this problem(use hardware-acceleration to encode/transcode video on Orange Pi 5 using FFmpeg)? How? Thank you

Posted

sudo apt install gstreamer1.0-rockchip 
ERROR:
E: Unable to locate package gstreamer1.0-rockchip
E: Couldn't find any package by glob 'gstreamer1.0-rockchip'

Posted

I use this version https://github.com/nyanmisaka/ffmpeg-rockchip
of ffmpeg with Orange Pi5+ (rockchip-rk3588) Linux Debian.

 

For my test, the input.mp4 file is a 60 second recording from rtsp Reolink h264 Camera.
 

% ffmpeg -i input.mp4 -c:v h264_rkmpp -c:a aac -y output-h264.mp4

Input: Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 2560x1920, 8348 kb/s, 29.72 fps, 30 tbr, 90k tbn (default)
Output:  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 2560x1920, q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)

frame= 1804 fps=131 q=-0.0 Lsize=   15327kB time=00:01:00.10 bitrate=2089.1kbits/s dup=20 drop=1 speed=4.38x    
 

% ffmpeg -i input.mp4 -c:v hevc_rkmpp -c:a aac -y output-hevc.mp4

Input: Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 2560x1920, 8348 kb/s, 29.72 fps, 30 tbr, 90k tbn (default)

Output:  Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(progressive), 2560x1920, q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)

frame= 1804 fps=128 q=-0.0 Lsize=   15299kB time=00:01:00.10 bitrate=2085.3kbits/s dup=20 drop=1 speed=4.26x    
 

% du -b input.mp4 output-h264.mp4 output-hevc.mp4

63077390        input.mp4
15913277        output-h264.mp4
15978009        output-hevc.mp4

 

The rate of hardware encoding is around 130 fps with h264_rkmpp or hevc_rkmpp.

From a human perspective, there's no video quality difference between these files.
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines