英伟达TX2环境GStreamer通过RTSP实现从IP网络摄像机拉流

验证用IP摄像头有3个,刚开始没图像输出,后来多试几次,就正常了:
摄像头一(演示正常):
gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/34020000001320000001

root@nvidia-desktop:/media/012-gst-docs# gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/34020000001320000001
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]/34020000001320000001
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

摄像头二(演示正常):
gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/LiveMedia/ch1/Media1

root@nvidia-desktop:/media/012-gst-docs# gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/LiveMedia/ch1/Media1
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]/LiveMedia/ch1/Media1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 2
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
Missing element: VND.ONVIF.METADATA RTP depayloader
WARNING: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: No decoder available for type 'application/x-rtp, media=(string)application, payload=(int)107, clock-rate=(int)90000, encoding-name=(string)VND.ONVIF.METADATA, a-recvonly=(string)"", npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1, ssrc=(uint)2676502632'.
Additional debug info:
gsturidecodebin.c(921): unknown_type_cb (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279

** (gst-launch-1.0:26660): CRITICAL **: 16:43:29.016: file gstaudioringbuffer.c: line 2045 (gst_audio_ring_buffer_set_channel_positions): should not be reached
Redistribute latency...

摄像头三(演示正常):
gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/34020000001320000001

root@nvidia-desktop:/media/012-gst-docs# gst-launch-1.0 playbin uri=rtsp://admin:[email protected]/34020000001320000001
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]/34020000001320000001
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

** (gst-launch-1.0:26717): CRITICAL **: 16:44:36.211: file gstaudioringbuffer.c: line 2045 (gst_audio_ring_buffer_set_channel_positions): should not be reached
Redistribute latency...

程序实现:
1,基础源码:Basic tutorial 1: Hello world!

2,源码更换视频源:

#include 

int
main (int argc, char *argv[])
{
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Build the pipeline */

/*  
  //视频源1(默认)
  pipeline =
      gst_parse_launch
      ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
      NULL);
*/      
/*
  //视频源2(IP摄像头)
  pipeline =
      gst_parse_launch
      ("playbin uri=rtsp://admin:[email protected]/34020000001320000001",
      NULL);
*/

///*
  //视频源3(IP摄像头)
  pipeline =
      gst_parse_launch
      ("playbin uri=rtsp://admin:[email protected]/LiveMedia/ch1/Media1",
      NULL);
//*/
/*

  //视频源4(IP摄像头)
  pipeline =
      gst_parse_launch
      ("playbin uri=rtsp://admin:[email protected]/34020000001320000001",
      NULL);      
*/      

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg =
      gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
      GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

3,编译 + 执行:

root@nvidia-desktop:/media/012-gst-docs/gst-docs/examples/tutorials# gcc basic-tutorial-1.c -o basic-tutorial-1 `pkg-config --cflags --libs gstreamer-1.0`
root@nvidia-desktop:/media/012-gst-docs/gst-docs/examples/tutorials# ./basic-tutorial-1
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

以上本人亲自验证正常(验证更多截图不方便上传),谢谢!

(完)

你可能感兴趣的:(英伟达TX2环境GStreamer通过RTSP实现从IP网络摄像机拉流)