Complete Guide: Rockchip Hardware Acceleration & Automated Conversion

Rockchip Hardware Acceleration Guide
Rockchip Guide Banner

Rockchip Hardware Acceleration & Automated Conversion

Last updated:

A complete guide to enabling hardware acceleration and setting up an automated conversion service on your Rockchip-powered SBC. This post will walk you through installing the necessary drivers and deploying a systemd service to watch for and convert video files automatically.

Part 1: Installing Hardware Acceleration Libraries

For ffmpeg to use your Rockchip VPU (Video Processing Unit), it needs the correct driver libraries. There are two primary methods to get these essential components installed on your system.

Method A: Using a PPA (Recommended)

This is the easiest and most reliable method as it uses a pre-built package archive.

  1. Install PPA Tool:
    sudo apt update
    sudo apt install software-properties-common -y
  2. Add Rockchip PPA:
    sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia
  3. Update & Install:
    sudo apt update
    sudo apt install rockchip-multimedia-config -y

Method B: Manual Installation

If the PPA command fails, you can add the repository manually.

  1. Add GPG Key:
    curl -s "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x8065BE1FC67AABDE" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/rockchip-multimedia.gpg >/dev/null
  2. Add Repository Source:
    echo "deb [signed-by=/etc/apt/trusted.gpg.d/rockchip-multimedia.gpg] https://ppa.launchpadcontent.net/liujianfeng1994/rockchip-multimedia/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/rockchip-multimedia.list
  3. Update & Install:
    sudo apt update
    sudo apt install rockchip-multimedia-config -y

Part 2: The Automation Scripts and Service

This service automatically finds and converts your files. It consists of a conversion script and two systemd files to manage and schedule it.

1. The Conversion Script

This script finds HEVC files, converts them using hardware acceleration, and deletes the original upon success. Save it as /home/manupa/bin/convert_hevc.sh.

#!/bin/bash
WATCH_DIR="/home/manupa/Downloads/SD/TVSeries"
LOG_FILE="/home/manupa/Downloads/converter.log"

log() { echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"; }

log "--- Starting conversion scan ---"
find "$WATCH_DIR" -type f \( -iname "*hevc*.mkv" -o -iname "*h265*.mkv" \) | while IFS= read -r i; do
    o="$(dirname "$i")/$(basename "$i" .mkv).mp4"
    log "Found: $i"
    if [ -f "$o" ]; then
        log "Skipping, output exists. Deleting original: $i"
        rm "$i"
        continue
    fi
    log "Converting to: $o"
    ffmpeg -c:v hevc_rkmpp -i "$i" -c:v h264_rkmpp -c:a copy "$o"
    if [ $? -eq 0 ]; then
        log "SUCCESS. Deleting original: $i"
        rm "$i"
    else
        log "ERROR: ffmpeg failed on $i"
    fi
done
log "--- Scan finished ---"

2. Systemd Service

Tells systemd what to run. Save as hevc_converter.service.

[Unit]
Description=HEVC to H264 Conversion Service

[Service]
Type=oneshot
ExecStart=/home/manupa/bin/convert_hevc.sh

3. Systemd Timer

Tells systemd when to run it. Save as hevc_converter.timer.

[Unit]
Description=Run HEVC converter every 30 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=30min
Unit=hevc_converter.service

[Install]
WantedBy=timers.target

Part 3: Full Setup Procedure

  1. Create Directories & Files:

    Create the necessary directories and place the service/timer files from Part 2 into /home/manupa/.config/systemd/user/.

    mkdir -p /home/manupa/bin
    mkdir -p /home/manupa/.config/systemd/user
  2. Make Script Executable:
    chmod +x /home/manupa/bin/convert_hevc.sh
  3. Enable and Start the Timer:

    This command must be run without `sudo`.

    systemctl --user enable --now hevc_converter.timer
  4. Enable User Linger (For Servers):

    This ensures your timer runs even when you are not logged in. This command requires sudo.

    sudo loginctl enable-linger $(whoami)

Rockchip Guide ©

1 Comments

  1. Make sure the system has enough RAM, because it will crash the system if it is too low

    ReplyDelete