前言:
RK3399Pro拥有六路1080P30帧解码能力,很多开发者不知道如何快速搭建这么一个Demo,这里我们社区开发者团队编写了一套Toybrick简单上手的python库,可以让大家快速上手编写各种demo。
该库目前还在非常早期的测试版本阶段,还未正式发布。并且需要注意以下几点:
思路分析:
RK3399Pro的VPU支持多路编解码,主控想完成多路编解码并显示,需要有一些开发技巧:
逻辑代码:
#!/usr/bin/env python3.6
import os
import toybrick as toy
import time
import threading
def func_rtspdisplay(gl, index, url, usr, pwd):
rtsp = toy.input.createRtspClient(url, usr, pwd)
rtsp.connect()
last = time.time()
while rtsp.is_opened():
frame = rtsp.read_rgb(640, 360)
now = time.time()
gl.show(index, frame)
print("> [%d] got frame. use = %f s" % (index, now - last))
last = now
print('# End of Thread %d' % (index))
if name == 'main':
os.system('iptables -F') # Disable Firewall
gl = toy.output.createGLDrmDisplay(toy.DisplayPort.HDMI_A)
idx0 = gl.add_view(0, 180, 640, 360)
idx1 = gl.add_view(640, 180, 640, 360)
idx2 = gl.add_view(1280, 180, 640, 360)
idx3 = gl.add_view(0, 540, 640, 360)
idx4 = gl.add_view(640, 540, 640, 360)
idx5 = gl.add_view(1280, 540, 640, 360)
t0 = threading.Thread(target=func_rtspdisplay, args = (gl, idx0, "rtsp://192.168.169.13/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t1 = threading.Thread(target=func_rtspdisplay, args = (gl, idx1, "rtsp://192.168.169.16/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t2 = threading.Thread(target=func_rtspdisplay, args = (gl, idx2, "rtsp://192.168.169.13/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t3 = threading.Thread(target=func_rtspdisplay, args = (gl, idx3, "rtsp://192.168.169.16/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t4 = threading.Thread(target=func_rtspdisplay, args = (gl, idx4, "rtsp://192.168.169.13/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t5 = threading.Thread(target=func_rtspdisplay, args = (gl, idx5, "rtsp://192.168.169.16/cam/realmonitor?channel=1&subtype=0", "admin", "admin123"))
t0.start()
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()
t0.join()
t1.join()
t2.join()
t3.join()
t4.join()
t5.join()
代码解析:
该套库的特点:
原作者:jefferyzhang
更多回帖