首页 > 其他分享 >gstreamer入门

gstreamer入门

时间:2022-10-31 16:04:49浏览次数:86  
标签:inspect 1.0 入门 stream launch gstreamer caps gst


Basics

gstreamer consists of gst-launch-1.0 and gst-inspect-1.0
gst-launch-1.0 launches a new stream pipeline with the properties you set.
gst-inspect-1.0 provides information on installed gstreamer modules
The ! connects the filters, but in gstreamer terminology they are called pads. The entire system of pads and filters is called a pipeline.


the most basic stream

This stream launches the video test source and pipes it to the screen.
​​​gst-launch-1.0 videotestsrc ! autovideosink​


Adding caps to the stream

Gstreamer has a filter called capabilities, caps for short. That changes some properties of the stream.
​​​gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480 ! autovideosink​​​
this is actually a short hand for
​​​gst-launch-1.0 videotestsrc ! capsfilter caps=video/x-raw,width=640,height=480 ! autovideosink​


Feed from the camera


Feed from screengrabber


Encode your stream

The videostreams that previously has been piped to autovideosink is now piped to the encoder pad with for example ​​! jpegdec​​​ for mjpeg encoding. Those encoders have multiple elements that can be changed to create the stream you want. A complete list can be provided ​​by gst-inspect-1.0 encoder-name​​.


Payload the stream

Payloading is the step of packing the data, raw or compressed into a network protocol. You can either use GDP (Gstreamer data protocol) or RTP (Real time protocol).
The payloader pad is simply added after the decoder pad in this fashion:
​​​! jpegenc ! rtpjpegpay​​​
If you have a dedicated high bandwidth connection you could skip the encoding step and just payload the raw stream:
​​​! rtpvrawpay​


Send the stream

There are multiple ways to send this stream to be used by other recipients on a network. ​​gst-inspect-1.0 | grep sink​​​ will show you all possibilities. In this tutorial I will only cover the autovideosink, the udpsink and the multiudpsink.
udpsink and multiudpsink are two similar sinks. The data piped to them is sent to one (udpsink) or several (multiudpsink) udp-adresses. ​​​udpsink host=127.0.0.1 port=5000​​​ sends the stream to the localhoast ​​multiudpsink clients=127.0.0.1:5000,127.0.0.1:5004,192.168.2.15:2000​​ sends it to three different destinations.


Receive the stream

​gst-launch-1.0 udpsrc port=5000​​​ will give you a connection, but that is not going to be interpreted correctly. To do that we need to add the caps filter from the sender.
​​​gst-launch-1.0 udpsrc port=5000 caps =xxx​


Unpack the payload

​! rtpjpegdepay​​ are the pads that can handle the unpacking.


Decode the format

The decoding of the format is also mostly quite straight forward.
add the pads ​​​! jpegdec​​ to your pipeline to decode the video.


Display the video

add ​​! autovideosink​​ again and it will be displayed on your screen.


Gst-inspect

​gst-inspect-1.0 | grep sink​​​ gives you a list of available sinks and ​​gst-inspect-1.0 | grep src​​​ gives you the available sources.
​​​gst-inspect-1.0 fpsdisplaysink​​ shows information on a special kind of video sink for example.


example

//sender
gst-launch-1.0 videotestsrc ! capsfilter caps=video/x-raw,width=640,height=480 ! jpegenc ! rtpjpegpay ! udpsink host=dest_ip_addr port=5555
//receiver
gst-launch-1.0 udpsrc port=5555 ! capsfilter caps=application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideoconvert ! autovideosink

参考文章

  1. ​Gstreamer basic real time streaming tutorial​
  2. 2.


标签:inspect,1.0,入门,stream,launch,gstreamer,caps,gst
From: https://blog.51cto.com/u_15854579/5810112

相关文章

  • MATLAB入门实验-MATLAB实验1...MATLAB实验8
    MATLAB入门实验-MATLAB实验1...MATLAB实验8实验1MATLAB系统环境运算基础一、实验目的掌握启动和退出MATLAB的方法。掌握MATLAB操作界面的组成。掌握建立矩阵的方法......
  • Solr 8.11入门教程(2)创建core
    新建core添加core命令添加使用命令比较简单~$bin/solrcreate-cmytest[core名称]这样就添加完了。CoreAdmin就可以看到了。手动添加手动添加相对复杂一些,需要提......
  • Solr 8.11入门教程(2)创建core
    新建core添加core命令添加使用命令比较简单~$bin/solrcreate-cmytest[core名称]这样就添加完了。CoreAdmin就可以看到了。手动添加手动添加相对复杂一些,需要提前创建目......
  • Hibernate的入门(概念1):
    什么是持久化类? 持久化类的编写规则? 区分自然主键和代理主键? 主键生成策略?  ......
  • Hibernate的入门(增删改查):
    注意:本次的记录是在上一篇Hibernate入门的基础上应用的1.目录2.实体类修改1packagecom.itheima.domain;23/*4*客户的javaBean5*@authorchenyanlong6*/......
  • Solr 8.11入门教程(2)新建core
    Solr8.11入门教程(2)新建core添加core命令添加使用命令比较简单~$bin/solrcreate-cmytest[core名称]这样就添加完了。CoreAdmin就可以看到了。手动添加手动......
  • Macbook pro 入门
    目录查看版本重置密码查看版本左上角苹果图标->AboutThisMac重置密码关机长按开机(右上角指纹按钮)直到出现"loadingstartupoption"加载完成后,点击顶层的"......
  • XAF新手入门 - 数据字典示例
    前言通过前面文章的介绍,大家应该对模块与类型子系统有所了解,再通过一个示例来加深大家对它的理解。在准备写这个系列文章之前,就准备是概念+示例的组合,这样大家对概念的......
  • SpringMVC入门(详解1)
    SpringMVC介绍:Springwebmvc属于表现层的框架,它是Spring框架的一部分,我们可以从Spring的整体结构中看得出来:springMVC详解: 使用范围: 执行流程:架构:文字描述:用户发送请求......
  • linux入门(隐私版)
    1操作系统的概述:1.1操作系统:操作系统作为接口的示意图:注意:大数据(电脑配置:内存16g,固态520g)1.2不同的操作系统1.2.1桌面操作系统1.2.2服务器操作系统 1.2.3嵌入式操作系统 L......