GStreamer入门教程源代码解析:basic-tutorial-1.c

53 篇文章 23 订阅
27 篇文章 4 订阅

源代码 basic-tutorial-1.c 如下:

#include <gst/gst.h>

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

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

  /* Build the pipeline */
  pipeline =
      gst_parse_launch
      ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
      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;
}

这段代码简单概括如下

	gst_init(...);
	pipeline = gst_parse_launch("...", NULL);
	gst_element_set_state (pipeline, GST_STATE_PLAYING);
	bus = gst_element_get_bus (pipeline);
	msg =  gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,  GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
	...
gst_parse_launch
gst_element_set_state
gst_element_get_bus
gst_bus_timed_pop_filtered
source
pipeline
bus
msg

正好手头有一个大华IP摄像机,把连接串改一下连上看看:

  pipeline =
      gst_parse_launch
      ("playbin uri=rtsp://admin:xxx@192.168.xxx.xxx:554/cam/realmonitor?channel=1&subtype=0",
      NULL);

在这里插入图片描述当然,在命令行下直接输入下面的命令也可以达到同样效果:

gst-launch-1.0 rtspsrc location="rtsp://admin:xxx@192.168.xxx.xxx:554/cam/realmonitor?channel=1&subtype=0" latency=0 ! decodebin ! videoconvert ! xvimagesink
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

许野平

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值