gstreamer应用笔记
gstreamer官网
https://gstreamer.freedesktop.org/
应用手册
https://gstreamer.freedesktop.org/documentation/index.html
一、getreamer安装(ubuntu)
gstreamer0.10和gstreamer1.0两个版本容易混淆
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install build-essential dpkg-dev flex bison autotools-dev automake liborc-dev autopoint libtool gtk-doc-tools libgstreamer1.0-dev
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev
gstreamer0.10-tools gstreamer0.10-plugins-base
libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good
gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad
gstreamer0.10-ffmpeg
sudo apt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-tools gstreamer0.10-doc
sudo apt-get install gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse
若有需要还可以再安装如下gst插件:
gstreamer0.10-tools
gstreamer0.10-x
gstreamer0.10-plugins-base
gstreamer0.10-plugins-good
gstreamer0.10-plugins-ugly
gstreamer0.10-plugins-bad
gstreamer0.10-ffmpeg
gstreamer0.10-alsa
gstreamer0.10-schroedinger
gstreamer0.10-pulseaudio
有可能需要安装的软件:
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install zlib1g
mad解码插件
apt-get install libmad0-dev
apt-get install gstreamer0.10-plugins-ugly
安装音频库
sudo apt-get install gstreamer1.0-alsa
安装ffmpeg多媒体库
gst-ffmpeg
--enable-liba52 enable GPLed liba52 support [default=no]
--enable-liba52bin open liba52.so.0 at runtime [default=no]
--enable-libamr-nb enable libamr-nb floating point audio codec
--enable-libamr-wb enable libamr-wb floating point audio codec
--enable-libfaac enable FAAC support via libfaac [default=no]
--enable-libfaad enable FAAD support via libfaad [default=no]
--enable-libfaadbin open libfaad.so.0 at runtime [default=no]
--enable-libgsm enable GSM support via libgsm [default=no]
--enable-libmp3lame enable MP3 encoding via libmp3lame
--enable-libvorbis enable Vorbis encoding via libvorbis,
native implementation exists [default=no]
--enable-libx264 enable H.264 encoding via x264 [default=no]
--enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [default=no]
插件太多了,几百上千个
List of Elements and Plugins
https://gstreamer.freedesktop.org/documentation/plugins.html
一劳永逸
sudo apt-get install gstreamer-plugins-*
sudo apt-get install gstreamer-*
二、 千里之行,始于"hello,world"
Basic tutorial 1: Hello world!
Basic tutorial 2: GStreamer concepts
Basic tutorial 3: Dynamic pipelines
Basic tutorial 4: Time management
Basic tutorial 5: GUI toolkit integration
Basic tutorial 6: Media formats and Pad Capabilities
Basic tutorial 7: Multithreading and Pad Availability
Basic tutorial 8: Short-cutting the pipeline
Basic tutorial 9: Media information gathering
Basic tutorial 10: GStreamer tools
Basic tutorial 11: Debugging tools
Basic tutorial 13: Playback speed
Basic tutorial 14: Handy elements
Basic tutorial 16: Platform-specific elements
除了这16个入门samples,后面的pipelines Command line tools 和 Plugin 插件开发也是多媒体类应用极好的教材
官网才是最应该多关注的地方
https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html
wiki手册也非常全面,几乎所有应用方向都说明
http://wiki.oz9aec.net/index.php?title=Gstreamer_cheat_sheet
IBM社区gstreamer教程
https://www.ibm.com/developerworks/cn/linux/l-gstreamer/
三、 gstreamer 进阶...
1、播放视频文件
以MP4格式为例,其它格式可以 通过gst-inspect-1.0 | grep 查找对应的demux,decode,sink等插件,当然也可以使用auto开头的插件,或者playbin会自动选择播放,只是没有自己指定那么灵活,方便调试和验证一些功能。
1)硬解(vaapi)播放MP4文件:
gst-launch-1.0 filesrc location=FilePath/test.mp4 ! qtdemux ! vaapidecode ! vaapisink
2) 软解,只要将解码器vaapidecode换成avdec_h264,播放器vaapisink换成 ximagesink即可
2、播放RTSP视频流
1) 硬解。
gst-launch-1.0 rtspsrc location=rtsp://username:passwd@ipaddr:port latency=0 ! rtph264depay ! capsfilter caps="video/x-h264" ! h264parse ! vaapidecode ! vaapipostproc width=800 height=600 ! vaapisink sync=false
2)软解。
gst-launch-1.0 rtspsrc location=rtsp://username:passwd@ipaddr:port latency=0 ! rtph264depay ! capsfilter caps="video/x-h264" ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=800,height=600 ! ximagesink
3、 播放Udp视频流
Udp播放需要根据发送端数据源封装格式来决定采用哪些Gstreamer插件,如果进行了RTP封装,则需要先用rtph264depay进行解包,如果包含自定义帧头的情况,应该编程对帧头进行处理,不然会显示异常,比如部分花屏现象,以下是对裸流进行播放。
1)硬解
gst-launch-1.0 udpsrc port=2101 ! h264parse ! vaapidecode ! vaapisink
2)软解
gst-launch-1.0 udpsrc port=2101 ! h264parse ! avdec_h264 ! autovideosink
参考https://blog.csdn.net/manjiao4651538/article/details/80227966
4、gstreamer rtsp推流/拉流
1)gstreamer rtsp拉流播放
https://blog.csdn.net/yang_quan_yang/article/details/78846134
2)gstereamer rtsp推流
https://blog.csdn.net/zhuwei622/article/details/80348916
3) On the Raspberry:
$ gst-launch-1.0 rtspsrc location=rtsp://192.168.2.112:8080/stream.sdp ! rtph264depay ! h264parse ! omxh264dec ! autovideosink
5、rtpbin Network/RTP
send
Encode and payload H263 video captured from a v4l2src. Encode and payload AMR audio generated from audiotestsrc. The video is sent to session 0 in rtpbin and the audio is sent to session 1. Video packets are sent on UDP port 5000 and audio packets on port 5002. The video RTCP packets for session 0 are sent on port 5001 and the audio RTCP packets for session 0 are sent on port 5003. RTCP packets for session 0 are received on port 5005 and RTCP for session 1 is received on port 5007. Since RTCP packets from the sender should be sent as soon as possible and do not participate in preroll, sync=false and async=false is configured on udpsink
gst-launch-1.0 rtpbin name=rtpbin \
v4l2src ! videoconvert ! ffenc_h263 ! rtph263ppay ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! udpsink port= \
rtpbin.send_rtcp_src_0 ! udpsink port= sync=false async=false \
udpsrc port= ! rtpbin.recv_rtcp_sink_0 \
audiotestsrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1 \
rtpbin.send_rtp_src_1 ! udpsink port= \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false \
udpsrc port= ! rtpbin.recv_rtcp_sink_1
recv
Receive H263 on port 5000, send it through rtpbin in session 0, depayload, decode and display the video. Receive AMR on port 5002, send it through rtpbin in session 1, depayload, decode and play the audio. Receive server RTCP packets for session 0 on port 5001 and RTCP packets for session 1 on port 5003. These packets will be used for session management and synchronisation. Send RTCP reports for session 0 on port 5005 and RTCP reports for session 1 on port 5007.
gst-launch-1.0 -v rtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" \
port= ! rtpbin.recv_rtp_sink_0 \
rtpbin. ! rtph263pdepay ! ffdec_h263 ! xvimagesink \
udpsrc port= ! rtpbin.recv_rtcp_sink_0 \
rtpbin.send_rtcp_src_0 ! udpsink port= sync=false async=false \
udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
port= ! rtpbin.recv_rtp_sink_1 \
rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink \
udpsrc port= ! rtpbin.recv_rtcp_sink_1 \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false
参考:
GStreamer RTP Streaming
https://community.nxp.com/docs/DOC-94646
6、录音
录音:
gst-launch -e pulsesrc ! audioconvert ! lamemp3enc target= bitrate= cbr=true ! filesink location=audio.mp3 gst-launch -e pulsesrc device="alsa_input.pci-0000_02_02.0.analog-stereo" ! audioconvert ! \
lamemp3enc target= bitrate= cbr=true ! filesink location=audio.mp3
播放录音:
gst-launch-1.0 filesrc location=audio.mp3 ! decodebin ! audioconvert ! audioresample ! autoaudiosink
还是上面的wiki
http://wiki.oz9aec.net/index.php?title=Gstreamer_cheat_sheet
7、录视频
命令:gst-launch-1.0 -e rtspsrc location=rtsp://admin:admin@192.168.1.2 ! rtph264depay ! "video/x-h264, stream-format=byte-stream" ! filesink location=test.264
说明:主要是用gst-lanuch工具连接相关插件将rtsp video stream 保存为.264文件,然后可以利用相关播放器(如:kmpplayer)进行播放,亦可以供live555MediaServer生成rtsp stream;("video/x-h264, stream-format=byte-stream"这个caps一定要连接才行)
原文:https://blog.csdn.net/u010005508/article/details/52710302
8、视频收发(监控,预览)
send:
gst-launch v4l2src ! video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! ffmpegcolorspace ! ffenc_h263 ! video/x-h263 ! rtph263ppay pt=96 ! udpsink host=127.0.0.1 port=5000 sync=false
recv:
gst-launch udpsrc port=5000 ! application/x-rtp, clock-rate=90000,payload=96 ! rtph263pdepay queue-delay=0 ! ffdec_h263 ! xvimagesink
以Freescale平台为例,实时码流收发命令行如下:
Server侧(发送方):
gst-launch -v videotestsrc ! video/x-raw-yuv,width=640,height=480 ! vpuenc codec=avc ! rtph264pay pt=96 ! udpsink host=127.0.0.1 port=1234
Client侧(接收方):
gst-launch -vvv udpsrc port=1234 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! vpudec ! mfw_isink
9、音频收发(语音对讲)
模拟声音数据
1)send.sh
gst-launch-1.0 rtpbin name=rtpbin \
audiotestsrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1 \
rtpbin.send_rtp_src_1 ! udpsink port= \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false \
udpsrc port= ! rtpbin.recv_rtcp_sink_1
2)recv.sh
gst-launch-1.0 -v rtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
port= ! rtpbin.recv_rtp_sink_1 \
rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink \
udpsrc port= ! rtpbin.recv_rtcp_sink_1 \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false
真实声卡
1) send.sh
gst-launch-1.0 rtpbin name=rtpbin \
pulsesrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1 \
rtpbin.send_rtp_src_1 ! udpsink port= \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false \
udpsrc port= ! rtpbin.recv_rtcp_sink_1
2) recv.sh
gst-launch-1.0 -v rtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
port= ! rtpbin.recv_rtp_sink_1 \
rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink \
udpsrc port= ! rtpbin.recv_rtcp_sink_1 \
rtpbin.send_rtcp_src_1 ! udpsink port= sync=false async=false
模拟声音和实际声卡只有发送端采集程序不同,模拟采集是audiotestsrc,实际声卡采集是pulsesrc
中国移动和对讲amr实时语音解码播放
gst-launch-1.0 udpsrc port= caps="application/x-rtp, media=(string)audio, clock-rate=(int)8000, encoding-name=(string)AMR, payload=(int)106" ! rtpamrdepay ! decodebin name=decoder ! queue ! audioconvert ! autoaudiosink
tcpdump -i eth0 -w dump.pcap
gstreamer中通过UDP(RTP)远程播放MP3
send.sh
gst-launch-1.0 -v filesrc location = Hopy_Always.mp3 ! decodebin ! audioconvert ! rtpL16pay ! udpsink host=127.0.0.1 port=6000
recv.sh
gst-launch-1.0 udpsrc port=6000 caps='application/x-rtp, media=(string)audio, clock-rate=(int)44100, channels=(int)2' ! rtpjitterbuffer latency=400 ! rtpL16depay ! pulsesink
Gstreamer 测试udpsink udpsrc播放mp3文件
https://blog.csdn.net/zhujinghao_09/article/details/8513962
10、gstreamer 播放mp3源码(播放器) ,入门开发极好的samples
https://blog.csdn.net/fireroll/article/details/49126827
https://www.cnblogs.com/274914765qq/p/5090299.html
11、Gstreamer的音视频同步
https://blog.csdn.net/maeom/article/details/7729840
12、播放音频
gst-launch-1.0 playbin uri=file:///home/dong/Hopy_Always.mp3
gst-launch-1.0 filesrc location=Hopy_Always.mp3 ! decodebin ! audioconvert ! audioresample ! autoaudiosink
13、Gstreamer视频传输测试gst-launch
https://blog.csdn.net/meng_tianshi/article/details/80142005
14、How to listen to the pulseaudio RTP Stream and play
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/RTP/
15、Gstreamer cheat sheet —— Picture in Picture / Video Wall / Text Overlay / Time Overlay ... ... ..
http://wiki.oz9aec.net/index.php?title=Gstreamer_cheat_sheet
16、用树莓派做 RTMP 流直播服务器,可推送至斗鱼直播
http://shumeipai.nxez.com/2017/11/01/build-rtmp-stream-live-server-with-raspberry-pi.html
17、gstreamer学习笔记:通过gst-launch工具抓取播放的音频数据并通过upd传输
gst-launch数据转换(pcm,aac,ts), rtp收发
https://blog.csdn.net/u010312436/article/details/53335579
18、gstreamer实现摄像头的远程采集,udp传输,本地显示和保存为AVI文件 发送端
send
https://blog.csdn.net/zhujinghao_09/article/details/8528802
recv
https://blog.csdn.net/zhujinghao_09/article/details/8528879
19、QtGStreamer dvr
https://blog.csdn.net/lg1259156776/article/details/53413877
https://blog.csdn.net/xueyeguiren8/article/details/54581536
20、基于Gstreamer的实时视频流的分发
https://blog.csdn.net/sdjhs/article/details/51444934
21、gstreamer学习笔记:将音视频合成MPEG2-TS流并打包通过rtp传输
https://blog.csdn.net/u010312436/article/details/53668083
22、gstreamer之RTSP Server一个进程提供多路不同视频
https://blog.csdn.net/quantum7/article/details/82999132
23、GStreamer资料整理(包括摄像头采集,视频保存,远程监控,流媒体RTP传输)
https://blog.csdn.net/wzwxiaozheng/article/details/6099397
24、使用GStreamer作v4l2摄像头采集和输出到YUV文件及屏幕的相关测试
https://blog.csdn.net/shallon_luo/article/details/5400708
25、Gstreamer中添加x265编解码器
https://blog.csdn.net/songwater/article/details/34855883
26、Gstreamer One Liners
https://metalab.at/wiki/Gstreamer_One_Liners
ARM平台基于嵌入式Linux Gstreamer 使用
https://www.eefocus.com/toradex/blog/16-05/379143_e4fcb.html
常见gstreamer pipeline 命令—— TI 3730 dvsdk
https://blog.csdn.net/songwater/article/details/34800017
gstreamer中的好东西,appsink和appsrc
https://blog.csdn.net/jack0106/article/details/5909935
基于DM3730平台的gstreamer音视频传输调试
https://blog.csdn.net/goalietech/article/details/24887955
gstreamer appsrc appsink应用
gstreamer向appsrc发送帧画面的代码
https://blog.csdn.net/quantum7/article/details/82226608
gstreamer向appsrc发送编码数据的代码
https://blog.csdn.net/quantum7/article/details/82250524
gstreamer学习笔记:分享几个appsink和appsrc的example
https://blog.csdn.net/u010312436/article/details/53610599
Here are two basic send/receive h264 video stream pipelines:
gst-launch-0.10 v4l2src ! ffmpegcolorspace ! videoscale ! video/x-raw-yuv,width=640,height=480 ! vpuenc ! h264parse ! rtph264pay ! udpsink host=localhost port=5555
gst-launch-0.10 udpsrc port=5555 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! ffdec_h264 ! videoconvert ! ximagesink
gstreamer使用进阶
https://blog.csdn.net/jack0106/article/details/5592557
# 整理了这么多,梳理一下指令,组织一下模块代码,应付常规的多媒体应用绰绰有余了!
gstreamer应用笔记的更多相关文章
- openwrt gstreamer实例学习笔记(七. gstreamer 缓冲区(Buffers)和事件(Events))
1)概述 管道的数据流由一组缓冲区和事件组成,缓冲区包括实际的管道数据,事件包括控制信息,如寻找信息和流的终止信号.所有这些数据流在运行的时候自动的流过管道. 2) 缓冲区(Buffers) 缓冲区包 ...
- openwrt gstreamer实例学习笔记(六. gstreamer Pads及其功能)
一:概述 如我们在Elements一章中看到的那样,Pads是element对外的接口.数据流从一个element的source pad到另一个element的sink pad.pads的功能(cap ...
- openwrt gstreamer实例学习笔记(五. gstreamer BUS)
1)概述 BUS(总线) 是一个简单的系统,它采用自己的线程机制将一个管道线程的消息分发到一个应用程序当中.总线的优势是:当使用GStreamer的时候,应用程序不需要线程识别,即便GStreamer ...
- openwrt gstreamer实例学习笔记(四. gstreamer Bins)
1)概述 Bins是一种容器element.你可以往Bins中添加element.由于Bins本身也是一种element,所以你可以像普通element一样 操作Bins.因此,先前关element的 ...
- openwrt gstreamer实例学习笔记(三.深入了解gstreamer 的 Element)
在前面的部分,我们简要介绍过 GstElementFactory 可以用来创建一个element的实例,但是GstElementFactory不仅仅只能做这件事,GstElementFactory作为 ...
- openwrt gstreamer实例学习笔记(二.gstreamer 的 Element)
对程序员来说,GStreamer 中最重要的一个概念就是 GstElement 对象.该对象是构建一个媒体管道的基本块.所有上层(high-level)部件都源自GstElement对象.任何一个解码 ...
- openwrt gstreamer实例学习笔记(一.初始化gstreamer)
GStreamer 是一个非常强大而且通用的流媒体应用程序框架. GStreamer所具备的很多优点来源于其框架的模块化: GStreamer能够无缝的合并新的插件. 但是, 由于追求模块化和高效率, ...
- Gstreamer学习
Gstreamer学习笔记----Gstreamer架构设计思想 http://blog.csdn.net/tx3344/article/details/7497434 Gstreamer到底是个啥? ...
- 【miscellaneous】 GStreamer应用开发手册学习笔记之基础概念介绍
第3章. 基础概念介绍 本章将介绍GStreamer的基本概念. 理解这些概念对于你后续的学习非常重要,因为后续深入的讲解我们都假定你已经完全理解了这些概念. 3.1. 元件(Elements) 元件 ...
随机推荐
- VMWare虚拟机提示:打不开磁盘…或它所依赖的某个快照磁盘,开启模块DiskEarly的操作失败,未能启动虚拟机
将电脑上存在的虚拟机复制一份后打开运行,弹出错误提示: 打不开磁盘…或它所依赖的某个快照磁盘,开启模块DiskEarly的操作失败,未能启动虚拟机. 解决方法如下: 打开存放虚拟机系统硬盘的所在文件夹 ...
- VS2008 Output窗口自动滚动
Output窗口默认是自动滚动的,活动光标始终处于最后一行. 但是有时候因为某些操作可能导致Output窗口的自动滚动停止. 如何恢复自动滚动呢? 使用快捷键操作即可:Ctrl + End
- mybatis由浅入深day02_6延迟加载_延迟加载总结
6 延迟加载 6.1 什么是延迟加载 需要查询关联信息时,使用mybatis延迟加载特性可有效的减少数据库压力,首次查询只查询主要信息,关联信息等用户获取时再加载. resultMap可以实现高级映射 ...
- day06<面向对象>
面向对象(面向对象思想概述) 面向对象(类与对象概述) 面向对象(学生类的定义) 面向对象(手机类的定义) 面向对象(学生类的使用) 面向对象(手机类的使用) 面向对象(一个对象的内存图) 面向对象( ...
- 九度 1547 出入栈(递推DP)
题目描述: 给定一个初始为空的栈,和n个操作组成的操作序列,每个操作只可能是出栈或者入栈.要求在操作序列的执行过程中不会出现非法的操作,即不会在空栈时执行出栈操作,同时保证当操作序列完成后,栈恰好为一 ...
- js array.filter实例(数组去重)
语法: 循环对数组中的元素调用callback函数, 如果返回true 保留,如果返回false 过滤掉, 返回新数组,老数组不变 var new_array = source_array.filt ...
- 图片上传根据stream生成image
对于图片上传代码的整合 因为需要判断上传的图片的宽高是否符合尺寸,所以在最初拿到inputstream的时候,就直接获取image格式的图片 本来是想在下面的checkFile中获取的,不过直接使用S ...
- Java中DESKeySpec类
此类位于 javax.crypto.spec 包下.声明如下: public class DESKeySpec extends Object implements KeySpec 此类指定一个 DES ...
- CSS-项目中遇到IE兼容问题,处理随笔
总是忘记给ie做特殊样式处理,以前打游击,不做也就算了,以后可不行,得对自己的“孩子”负责.. 一.先说IE老大的兼容 知道了一些常用的css属性兼容方法确实可以解决问题, 但我不知道我自己的ieTe ...
- 使用CDN的网络访问过程
CDN是指内容分发网络,在网络各处架设节点服务器,当用户访问时,CDN系统会根据网络流量.到用户的距离等因素将请求导向离用户最近的节点上. 访问过程是: 1.用户向浏览器提供要访问的域名. 2.浏览器 ...