[GStreamer] TX1 CPU and GPU decoding display Hikvision camera RTSP stream

      Hello everyone, I am Brother Hu. I found a set of Hikvision cameras today. I want to test DeepStream and use the RTSP stream of the network camera as input to see the subsequent target recognition and classification. But I still want to watch the video in real time first. Of course, I can choose VLC to view it. By the way, I also tested it with GStreamer, and compared the resource usage of CPU decoding and GPU decoding under the TX1 core module. Share it with everyone, and it is also my own Make a summary note.

        I found that the image size of the Hikvision camera is 1280X720, and the H.264 compression is used. Moreover, after installing the VLC player in my own system, I couldn't play the network stream. After searching for a long time, I couldn't solve it, so I still got the GStreamer test honestly.

Table of contents

1. Display network camera RTSP stream CPU decoding

1.1 Save a frame of photo

1.2 Display (NoMachine terminal) avdec_h264 CPU decoding

1.3 Basic information of avdec_h264 plug-in

2. GPU hardware decoding in TX1

1.1 Basic information of omxh264dec

1.2 Decoding display


1. Display network camera RTSP stream CPU decoding

#playbin 插件播放 需要显示器支持 NoMachine终端不显示
gst-launch-1.0 playbin uri= rtsp://admin:[email protected]:554/h264/ch1/main/av_stream
#子码流取流:
#playbin 插件播放 需要显示器支持 NoMachine终端不显示
gst-launch-1.0 playbin uri= rtsp://admin:[email protected]:554/h264/ch1/sub/av_stream

1.1 Save a frame of photo

#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:[email protected]:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse ! avdec_h264 \
! videorate ! jpegenc ! filesink location=./file_1280_720_img-1.jpg

1.2 Display (NoMachine terminal) avdec_h264 CPU decoding

gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse ! avdec_h264 \
! videorate ! xvimagesink

#第1种 CPU 解码 不进行调整帧率
gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]:554/h264/ch1/main/av_stream" \
latency=7  \
! rtph264depay ! h264parse \
! avdec_h264  \
! xvimagesink
​
#第2种 CPU 解码 进行调整帧率
gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]: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:[email protected]:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! avdec_h264 \
! xvimagesink
​
#第4种 CPU 解码  不进行调整帧率 sync 关闭
gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]:554/h264/ch1/main/av_stream" \
latency=7  \
! rtph264depay ! h264parse \
! avdec_h264 \
! xvimagesink sync=false 

default system resources

 Type 1: The CPU usage is significantly increased, and the screen fluency is acceptable

 Type 2: The CPU usage is significantly increased, and the screen fluency is acceptable, which is not much different from the first type

Type 3: The CPU usage is significantly increased, and the screen fluency is acceptable, but the delay is obviously several seconds

 Type 4: The CPU usage is significantly increased, the screen fluency is acceptable, and there is basically no delay

1.3 Basic information of avdec_h264 plug-in

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. GPU hardware decoding in TX1

1.1 Basic information of 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 <[email protected]>
​
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 Decoding display

#第1种 :GPU 解码 不使用latency cap
gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! omxh264dec  \
! videoconvert  \
! xvimagesink
​
#第2种 :GPU 解码 使用latency cap
gst-launch-1.0 rtspsrc \
location="rtsp://admin:[email protected]: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:[email protected]: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:[email protected]:554/h264/ch1/main/av_stream" \
! rtph264depay ! h264parse \
! omxh264dec  \
! videoconvert  \
! xvimagesink sync=false 
Type 1: There is a significant delay in the video

 Type 2: The alarm will be printed continuously, and the delay is obvious

 Type 3: No alarm, smooth video, no delay

Type 4: No difference from Type 3

The above is what I want to share today. Error correction, questions, communication:  [email protected]

Guess you like

Origin blog.csdn.net/cau_weiyuhu/article/details/129102319