4.5.0-beta有有GStreamer 硬件解码插件包吗

S100P烧录4.5.0版本后使用Gstreamer视频解码只有软解码,4.5.0-beta有有GStreamer 硬件解码插件包吗

可参考这个 https://horizonrobotics.feishu.cn/wiki/THC1wXLfwiXz6Dk9Dl7c6UQsnwf?from=from_copylink

你好现在这个查看不了,可以给新的链接么

image

平台判断

def is_RDK():
    try:
        tree = open('/sys/firmware/devicetree/base/model', 'r', encoding='utf-8').read()
        if "X5" in tree:
            return "rdkx5"
        if "S100" in tree:
            return "rdks100"
    except:
        return "None"

ubuntu安装gstreamer

前提条件

vim /usr/bin/hobot-loadko.sh

注释掉下述三句
# modprobe hobot_videosys &
# modprobe hobot_vpu &
# modprobe hobot_jpu &
重启系统

modprobe wave5

安装

# 基础组件与插件
sudo apt install -y \
  gstreamer1.0-tools \
  gstreamer1.0-plugins-base \
  gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-ugly \
  gstreamer1.0-libav
  
# v4l2硬编码组件
sudo apt install -y gstreamer1.0-plugins-bad

检查v4l2硬编码组件是否安装成功

gst-inspect-1.0 | grep v4l2

检查到包含以下属性说明硬编码组件安装成功。注意:要在对应的 vpu 驱动加载后再查看该信息

video4linux2:  v4l2h264dec: V4L2 H264 Decoder
video4linux2:  v4l2h264enc: V4L2 H.264 Encoder
video4linux2:  v4l2h265dec: V4L2 H265 Decoder
video4linux2:  v4l2h265enc: V4L2 H.265 Encoder

测试命令

输入png编码

硬解

  • 硬解
gst-launch-1.0 -e multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
  pngdec ! \
  videoconvert ! video/x-raw,format=I420 ! \
  v4l2h264enc extra-controls="encode,video_bitrate=2000000;" ! \
  h264parse ! \
  mp4mux streamable=true ! \
  filesink location=out_v4l2.mp4

real 0m21.822s

user 0m21.625s

sys 0m0.415s

  • 优化版本一:修改png解码格式,增加多线程
gst-launch-1.0 -e \
multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
decodebin ! videoconvert ! video/x-raw,format=I420 ! \
v4l2h264enc extra-controls="encode,video_bitrate=2000000;" ! \
h264parse ! mp4mux streamable=true ! \
filesink location=out_v4l2.mp4

real 0m21.882s

user 0m21.790s

sys 0m0.297s

  • 优化版本二:并行
gst-launch-1.0 -e \
multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
pngdec ! queue max-size-buffers=20 ! \
videoconvert n-threads=6 ! queue max-size-buffers=20 ! video/x-raw,format=I420 ! \
v4l2h264enc extra-controls="encode,video_bitrate=2000000" ! \
h264parse ! mp4mux streamable=true ! filesink location=out_v4l2.mp4

real 0m16.731s

user 0m21.685s

sys 0m0.340s

软解

gst-launch-1.0 -e multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
  pngdec ! \
  videoconvert ! video/x-raw,format=I420 ! \
  x264enc bitrate=2000 speed-preset=medium tune=zerolatency ! \
  h264parse ! \
  mp4mux streamable=true ! \
  filesink location=out_x264.mp4

real 0m51.155s

user 2m24.440s

sys 0m1.303s

使用gstreamer内置的测试视频源编码

gst-launch-1.0 -e videotestsrc num-buffers=100 ! \
  video/x-raw,width=1920,height=1080,framerate=30/1 ! \
  v4l2h264enc extra-controls="encode,video_bitrate=2000000;" ! \
  h264parse ! mp4mux ! filesink location=out_v4l2.mp4

配置码率需要打开开关

gst-launch-1.0 -e \
multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
pngdec ! queue max-size-buffers=20 ! \
videoconvert n-threads=6 ! queue max-size-buffers=20 ! video/x-raw,format=I420 ! \
v4l2h264enc extra-controls="encode,frame_level_rate_control_enable=1,video_bitrate=5000000" ! \
h264parse ! mp4mux streamable=true ! filesink location=out_v4l2.mp4

码率配置不生效的问题,用这里的命令。

码率控制功能默认未使能,编码器工作在固定QP模式,所以编码器不会根据配置的码率动态调整。增加的参数目的是使能码率控制。

RK

内置测试视频

gst-launch-1.0 -e videotestsrc num-buffers=100 ! \
  video/x-raw,width=1920,height=1080,framerate=30/1 ! \
  mpph264enc bps=2000000 ! \
  h264parse ! mp4mux ! filesink location=out_v4l2.mp4

输入png编码

sudo gst-launch-1.0 -e \
multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
pngdec ! queue max-size-buffers=10 ! \
videoconvert ! queue max-size-buffers=10 ! video/x-raw,format=I420 ! \
mpph264enc bps=2000000 ! \
h264parse ! mp4mux streamable=true ! filesink location=out_v4l2.mp4
real    0m17.958s
user    0m0.011s
sys     0m0.009s

NV

内置测试视频

gst-launch-1.0 -v \
videotestsrc ! "video/x-raw,width=1920,height=1080,framerate=30/1" ! \
nvvidconv ! "video/x-raw(memory:NVMM),format=NV12" ! \
nvv4l2h264enc bitrate=2000000 ! h264parse ! mp4mux ! filesink location=test.mp4

输入png编码

gst-launch-1.0 -v -e \
multifilesrc location="/home/jetson/v4l2/episode_000000/frame_%06d.png" index=0 caps="image/png,framerate=30/1" ! \
pngdec ! \
videoconvert ! \
nvvidconv ! \
nvv4l2h264enc bitrate=2000000 ! \
h264parse config-interval=1 ! mp4mux streamable=true ! \
filesink location=out_v4l2.mp4

real 0m16.280s

user 0m14.170s

sys 0m1.817s

不同平台耗时结果对比

场景:将分辨率为640x480分辨率的1800张png编码成mp4格式输出

执行命令 耗时
S100 ```
gst-launch-1.0 -e \
multifilesrc location=“/userdata/v4l2/episode_000000/frame_%06d.png” caps=“image/png,framerate=30/1” ! \
pngdec ! queue max-size-buffers=20 ! \
videoconvert n-threads=6 ! queue max-size-buffers=20 ! video/x-raw,format=I420 ! \
v4l2h264enc extra-controls=“encode,video_bitrate=2000000” ! \
h264parse ! mp4mux streamable=true ! filesink location=out_v4l2.mp4

user 0m21.685s

sys 0m0.340s|
|RK3576|```
sudo gst-launch-1.0 -e \
multifilesrc location="/userdata/v4l2/episode_000000/frame_%06d.png" caps="image/png,framerate=30/1" ! \
pngdec ! queue max-size-buffers=20 ! \
videoconvert ! queue max-size-buffers=20 ! video/x-raw,format=I420 ! \
mpph264enc bps=2000000 ! \
h264parse ! mp4mux streamable=true ! filesink location=out_v4l2.mp4
```|real 0m17.958s user 0m0.011s sys 0m0.009s|
|NV|```
gst-launch-1.0 -e \
multifilesrc location="/home/jetson/v4l2/episode_000000/frame_%06d.png" index=0 caps="image/png,framerate=30/1" ! \
pngdec ! \
videoconvert ! \
nvvidconv ! \
nvv4l2h264enc bitrate=2000000 ! \
h264parse config-interval=1 ! mp4mux streamable=true ! \
filesink location=out_v4l2.mp4
```|real 0m16.280s

user 0m14.170s

sys 0m1.817s|

可以提供一下这个 episode_000000路径下的文件么

这是png文件 ,自己找一些就好了