Xilinx Zynq UltraScale+ MPSoC VCU ROI Demo跑

一、前言

ZU7EV系列MPSoC集成了硬件视频编解码IP VCU,可进行H264/H265视频编解码。Xilinx提供了VCU参考TRD,此外,还提供了一个VCU+DPU的参考设计:Zynq UltraScale MPSoC VCU TRD。该wiki提供了2个下载地址,其中带v1.0是较新的(https://www.xilinx.com/member/forms/download/eula-xef.html?filename=vcu_roi_2019.2_v1.0.zip)。

整体框图如下:PL接收来自HDMI_RX的原始输入(NV12),经resize和转BGR送给DPU,进行人脸检测?,得到人脸的ROI信息,送给VCU,VCU对原始输入结合ROI信息进行Enc,然后对编码数据进行Dec送显示或直接通过GEM送出。

Xilinx Zynq UltraScale+ MPSoC VCU ROI Demo跑_第1张图片

二、Run

0)启动

解压下载的文件,把/vcu_roi_2019.2_v1.0/images/vcu_roi中的文件拷贝至SD卡,可以再拷个测试.mp4文件;ZCU106连接HDMI显示器(1080p@60)和HDMI输入(如笔记本的输出),连接网线、串口线到笔记本,SD卡启动ZCU106,串口显示系统启动。sd卡已经被mount到了/media/card/,运行DPU demo前需source /media/card/export.sh;

1)点亮屏幕

终端输入

modetest -D a0060000.v_mix -s 35:1920x1080-60@BG24 &

其中,1920x1080,60等参数需根据连接的显示器而定,屏幕由黑屏变成蓝色;

2)查看HDMI输入

xmedia-ctl -p -d /dev/media0

查看显示的“v_hdmi_rx_ss” ,大约在倒数2行处:
如果Conneced:[dv.detect:BT.656/1120
如果Unconnect:dv.query:no-link] -----> HDMI Rx Link Status

3)HDMI显示testsrc

gst-launch-1.0 videotestsrc ! kmssink bus-id="a0060000.v_mix"

将会显示一个gst-streamer生成的测试显示图案,可以加pattern=xx改变样式;

4)HDMI解码显示mp4文件

gst-launch-1.0 filesrc location="/media/card/drill.mp4" ! qtdemux ! h264parse ! omxh264dec ! kmssink bus-id="a0060000.v_mix"

gst-launch-1.0 uridecodebin uri="file:///media/card/drill.mp4" ! queue max-size-bytes=0 ! kmssink bus-id="a0060000.v_mix"

不知道是不是采用默认参数导致的编解码不匹配,显示帧顺序不太正常;

5)HDMI输入到输出(Passthrough)

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1 ! queue ! kmssink bus-id="a0060000.v_mix"

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1 ! xlnxroivideo1detect  capture-io-mode=4 output-io-mode=5 ! kmssink bus-id="a0060000.v_mix"

笔记本设置屏幕扩展,HDMI-TX显示HDMI-RX的数据,显示延时较小,20ms;
(后者使能了DPU,给出了ROI信息,但是没进编解码?)

6)HDMI输入到输出(关闭ROI)(RX->ENC->DEC->TX)

vcu_gst_app /media/card/config/1080p30/Display/Single_1080p30_AVC_5Mbps.cfg

使用默认的cfg文件,但是把ROI改成FALSE,延时500ms左右,或

 gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1 ! queue ! omxh264enc ! video/x-h264, profile=main, alignment=au ! omxh264dec ! kmssink bus-id="a0060000.v_mix"

其中3处264改为265可运行  ;

7)HDMI输入到输出(打开ROI)(RX->ROI->ENC->DEC->TX)

指令同上,把cfg文件的ROI改回TRUE,需export DPU_COMPILATIONMODE=1,或

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, width=1920, height=1080, format=NV12, framerate=30/1 ! xlnxroivideo1detect  capture-io-mode=4 output-io-mode=5 ! omxh265enc qp-mode=roi num-slices=8 prefetch-buffer=true gop-length=60 periodicity-idr=270 control-rate=low-latency target-bitrate=5000 gop-mode=low-delay-p cpb-size=200 initial-delay=100 filler-data=false min-qp=15 max-qp=40 b-frames=0 low-bandwidth=false ! video/x-h265, profile=main, alignment=au ! queue ! omxh265dec internal-entropy-buffers=5 low-latency=0 ! queue max-size-bytes=0 ! fpsdisplaysink text-overlay=false video-sink="kmssink bus-id="a0060000.v_mix""

延时接近500ms;265改264可运行;

8)HDMI输入到文件(RX->ROI->ENC->File.ts)

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, format=NV12,width=1920,height=1080,framerate=30/1 ! xlnxroivideo1detect  capture-io-mode=4 output-io-mode=5 ! omxh265enc qp-mode=roi num-slices=8 prefetch-buffer=true gop-length=60 periodicity-idr=270 control-rate=low-latency target-bitrate=5000 gop-mode=low-delay-p cpb-size=200 initial-delay=100 filler-data=false min-qp=15 max-qp=40 b-frames=0 low-bandwidth=false ! video/x-h265, profile=main, alignment=au ! queue ! video/x-h265, profile=main, alignment=au ! mpegtsmux alignment=7 name=mux ! filesink location="/media/card/test.ts"

通过PC查看ts属性:编解码器: MPEG-H Part2/HEVC (H.265) (hevc);
可通过

gst-launch-1.0 uridecodebin uri="file:///media/card/test.ts" ! queue max-size-bytes=0 ! kmssink bus-id="a0060000.v_mix"

播放;

9)Stream Out(RX->ROI->ENC->RTP->Host:VLC_Player解码显示)

Host端:
  1.打开VLC Player; 
  2.媒体-打开网络串流;
  3.输入:rtp://192.168.0.100:5004 (或rtp://@:5004)此处为Host的IP和侦听端口号;
  4.点播放;
ZCU106端:(ifconfig eth0 192.168.0.106)

vcu_gst_app /media/card/config/1080p30/Stream-out/Single_1080p30_AVC_5Mbps.cfg 

需修改cfg文件的HOST IP和Port,修改为Host的(192.168.0.100和5004);或

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! xlnxroivideo1detect  capture-io-mode=4 output-io-mode=5 ! omxh265enc qp-mode=roi num-slices=8 prefetch-buffer=true gop-length=60 periodicity-idr=270 control-rate=low-latency target-bitrate=5000 gop-mode=low-delay-p cpb-size=200 initial-delay=100 filler-data=false min-qp=15 max-qp=40 b-frames=0 low-bandwidth=false ! video/x-h265, profile=main, alignment=au ! queue ! mpegtsmux alignment=7 name=mux ! rtpmp2tpay ! udpsink host=192.168.0.100 port=5004

(不卡)或

gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! omxh265enc ! video/x-h265, profile=main, alignment=au ! queue ! mpegtsmux alignment=7 name=mux ! rtpmp2tpay ! udpsink host=192.168.0.100 port=5004

(卡)

10)Stream In(Host:VLC_Player->ENC->RTP->ZCU106:DEC->TX)

Host端:
  1.VLC-Player
  2.媒体-流-选择本地文件,
   --串流-UDP-添加:192.168.0.106,5008;激活转码(选不选都行);流。
ZCU106端:修改cfg文件
  Input Type        : stream
  Uri                     : udp://192.168.0.106:5008)(填的是zcu106的)
运行

vcu_gst_app /media/card/config/1080p30/Stream-in/input.cfg

可播放来自网络的RTP编码流;


 

你可能感兴趣的:(Xilinx Zynq UltraScale+ MPSoC VCU ROI Demo跑)