大家好,我是虎哥,今天找了一套海康的相机,想后续测试一下DeepStream用网络相机RTSP流做输入看看后续目标识别和分类。但是还是想先实时看看视频,当然,可以选择VLC去查看,顺道我也用GStreamer 来测试了一下,并且对比了TX1核心模块下,CPU解码和GPU解码资源占用情况,分享给大家,也是自己做个笔记总结。
我自己找到海康相机的图像尺寸是1280X720的,采用了H.264的压缩。而且,我自己系统安装VLC播放器后没法播放网络流,搜了半天没有解决,所以还是老实搞定GStreamer 测试。
目录
1、显示网络相机RTSP流CPU解码
1.1保存一帧照片
1.2 显示(NoMachine终端)avdec_h264 CPU解码
1.3 avdec_h264 插件基本信息
2、TX1中GPU 硬件解码
1.1 omxh264dec 基本信息
1.2 解码显示
1、显示网络相机RTSP流CPU解码
#playbin 插件播放 需要显示器支持 NoMachine终端不显示
gst-launch-1.0 playbin uri= rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream
#子码流取流:
#playbin 插件播放 需要显示器支持 NoMachine终端不显示
gst-launch-1.0 playbin uri= rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/sub/av_stream
1.1保存一帧照片
#rtspsrc 指定数据来源,类似之前的v4l2 Receive data over the network via RTSP (RFC 2326)
#location 数据来源URL,需要可以使用playbin能播放
#rtph264depay 从RTSP数据流转接成H264 video Extracts H264 video from RTP packets (RFC 3984)
#avdec_h264 H.264解码 不是所有平台都有,先要查一下自己平台是否有这个插件
#h264parse 分析和缓冲H.264数据流 Parses H.264 streams
#videorate 调整帧率,优化视频流 Drops/duplicates/adjusts timestamps on video frames to make a perfect stream
#jpegenc 编码
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse ! avdec_h264 \
! videorate ! jpegenc ! filesink location=./file_1280_720_img-1.jpg
1.2 显示(NoMachine终端)avdec_h264 CPU解码
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse ! avdec_h264 \
! videorate ! xvimagesink
#第1种 CPU 解码 不进行调整帧率
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
latency=7 \
! rtph264depay ! h264parse \
! avdec_h264 \
! xvimagesink
#第2种 CPU 解码 进行调整帧率
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
latency=7 \
! rtph264depay ! h264parse \
! avdec_h264 ! videorate \
! xvimagesink
#第3种 CPU 解码 不进行调整帧率 不适用latency cap
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! avdec_h264 \
! xvimagesink
#第4种 CPU 解码 不进行调整帧率 sync 关闭
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
latency=7 \
! rtph264depay ! h264parse \
! avdec_h264 \
! xvimagesink sync=false
默认系统资源
第1种: CPU 占用明显增高,画面流畅度还算可以接受
第2种: CPU 占用明显增高,画面流畅度还算可以接受,与第一种差别不大
第3种: CPU 占用明显增高,画面流畅度还算可以接受,但是延时明显好几秒
第4种: CPU 占用明显增高,画面流畅度还算可以接受,也基本没有延时
1.3 avdec_h264 插件基本信息
nvidia@ubuntu:~$ gst-inspect-1.0 avdec_h264
Pad Templates:
SRC template: 'src'
Availability: Always
Capabilities:
video/x-raw
format: { (string)I420, (string)YUY2, (string)RGB, (string)BGR, (string)Y42B, (string)Y444, (string)YUV9, (string)Y41B, (string)GRAY8, (string)RGB8P, (string)I420, (string)Y42B, (string)Y444, (string)UYVY, (string)NV12, (string)NV21, (string)ARGB, (string)RGBA, (string)ABGR, (string)BGRA, (string)GRAY16_BE, (string)GRAY16_LE, (string)A420, (string)RGB16, (string)RGB15, (string)I420_10BE, (string)I420_10LE, (string)I422_10BE, (string)I422_10LE, (string)Y444_10BE, (string)Y444_10LE, (string)GBR, (string)GBR_10BE, (string)GBR_10LE, (string)A420_10BE, (string)A420_10LE, (string)A422_10BE, (string)A422_10LE, (string)A444_10BE, (string)A444_10LE, (string)GBRA, (string)xRGB, (string)RGBx, (string)xBGR, (string)BGRx, (string)I420_12BE, (string)I420_12LE, (string)I422_12BE, (string)I422_12LE, (string)Y444_12BE, (string)Y444_12LE, (string)GBR_12BE, (string)GBR_12LE, (string)GBRA_12BE, (string)GBRA_12LE }
SINK template: 'sink'
Availability: Always
Capabilities:
video/x-h264
alignment: au
stream-format: { (string)avc, (string)byte-stream }
Element has no clocking capabilities.
Element has no URI handling capabilities.
Pads:
SINK: 'sink'
Pad Template: 'sink'
SRC: 'src'
Pad Template: 'src'
2、TX1中GPU 硬件解码
1.1 omxh264dec 基本信息
nvidia@ubuntu:~$ gst-inspect-1.0 omxh264dec
nvbuf_utils: Could not get EGL display connection
Factory Details:
Rank primary + 10 (266)
Long-name OpenMAX H.264 Video Decoder
Klass Codec/Decoder/Video
Description Decode H.264 video streams
Author Sebastian Dröge <sebastian.droege@collabora.co.uk>
Plugin Details:
Name omx
Description GStreamer OpenMAX Plug-ins
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so
Version 1.2.3
License LGPL
Source module gstreamer
Source release date 2014-02-08
Binary package GStreamer source release
Origin URL Unknown package origin
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
video/x-h264
parsed: true
alignment: au
stream-format: byte-stream
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
SRC template: 'src'
Availability: Always
Capabilities:
video/x-raw(memory:NVMM)
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-raw
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
Element has no clocking capabilities.
Element has no URI handling capabilities.
Pads:
SINK: 'sink'
Pad Template: 'sink'
SRC: 'src'
Pad Template: 'src'
1.2 解码显示
#第1种 :GPU 解码 不使用latency cap
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! omxh264dec \
! videoconvert \
! xvimagesink
#第2种 :GPU 解码 使用latency cap
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
latency=7 \
! rtph264depay ! h264parse \
! omxh264dec \
! videoconvert \
! xvimagesink
#第3种 :GPU 解码 使用latency cap,关闭显示sync=false
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
latency=7 \
! rtph264depay ! h264parse \
! omxh264dec \
! videoconvert \
! xvimagesink sync=false
#第4种 :GPU 解码 不使用latency cap,关闭显示sync=false
gst-launch-1.0 rtspsrc \
location="rtsp://admin:abcd1234@192.168.11.68:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! omxh264dec \
! videoconvert \
! xvimagesink sync=false
第1种:视频存在明显延时
第2种:会不断打印报警,并且延时明显
第3种:没有报警,视频流畅,没有延时
第4种:与第3种没有什么区别
以上就是我今天要分享的内容。纠错,疑问,交流: 911946883@qq.com