gstreamer入门
来源:互联网 发布:淘宝创业必备知识 编辑:程序博客网 时间:2024/06/12 08:42
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
//sendergst-launch-1.0 videotestsrc ! capsfilter caps=video/x-raw,width=640,height=480 ! jpegenc ! rtpjpegpay ! udpsink host=dest_ip_addr port=5555//receivergst-launch-1.0 udpsrc port=5555 ! capsfilter caps=application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideoconvert ! autovideosink
参考文章
- Gstreamer basic real time streaming tutorial 2.
- gstreamer入门
- Gstreamer入门小结
- Gstreamer Plugin 编写 之 入门
- Gstreamer Plugin 编写 之 入门
- gstreamer
- Gstreamer
- gstreamer
- gstreamer
- GStreamer
- GStreamer基础教程翻译-及原文地址,看懂后GStreamer就快速入门了
- gstreamer学习计划
- gstreamer 调试
- gstreamer开发
- 初探GStreamer
- GSTREAMER SMALL
- android gstreamer
- gstreamer vedio
- busybox & gstreamer
- 不使用流程控制语句,打印出1~100的整数
- 关于zabbix的安装
- Tensorflow中使用 LSTM + CTC 的例子
- 软考上午题难点5分钟攻克系列(三)
- SQL Server中的小數近似處理實例
- gstreamer入门
- django 使用 oracle 数据库的问题
- Map两种迭代方法
- 基类 派生类 算一个数乘积
- [LeetCode] Search in Rotated Sorted Array
- int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const
- 素数环
- echarts显示图表
- IOS开发要注意数组的赋值问题