GStreamer是著名的开源多媒体框架,功能强大,其命令行程序 gst-launch 可以实现很多常规测试、播放等,作为系统调试等是非常方便的。

1、摄像头测试

gst-launch v4l2src ! xvimagesink

gst-launch v4l2src ! video/x-raw-yuv,width=320,height=240,framerate=20/1 ! xvimagesink

上述命令不一定能够成功,或者出现的摄像头图像窗口没有正常的图像,这是因为摄像头支持的图像格式会有差别,gstreamer 默认采用的格式不被支持,这时可以尝试:

gst-launch v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=320,height=240 ! xvimagesink

基本上可以了。根据 gstreamer 的文档,针对 v4l2src 这个插件,能够支持的图像格式在这里有详细说明说明。这里要注意,强制指定图像格式是采用 format 参数,并且要用到 (fourcc) 指示字,必须带有括号的,但是在命令行下,括号是特殊含义字符,所以用 \ 反斜杠转意处理!这只是一个例子说明,你可以尝试确定你的摄像头到底支持哪种图像格式,然后就可以用通过 format 参数来指定了。

2、播放文件

gst-launch playbin uri=file:///path/to/test.avi

据说还有 playbin2 插件,采用的是新的播放解码。

具体有关 gstreamer 的一些资源参考:

http://blog.csdn.net/fancycow/article/details/7552520

http://blog.csdn.net/wzwxiaozheng/article/details/6099397

http://blog.csdn.net/shallon_luo/article/details/5400708

http://blog.csdn.net/wzwxiaozheng/article/details/6130818

http://blog.chinaunix.net/uid-10747583-id-282761.html

http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet#Webcam_Capture(重点推荐文章)

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-v4l2src.html

Gstreamer中一些gst-launch常用命令

用Linux系统中使用gstreamer架构做对媒体开发时,gst-inspect
和gst-launch是两个非常使用的小工具,gst-inspect 在开发时用于查询库各个插件element的详细信息,后者用于在终端快速构建一条pipeline用于播放多媒体。下面列出我在以前的学习和项目开发时常用的gst-launch播放各种多媒体文件的实例:

一、gstreamer实现视频显示

gst-launch videotestsrc ! xvimagesink

二、gstreamer实现摄像头采集:

1、可以现实图像,但图像卡住不动

gst-launch v4l2src ! xvimagesink

2、摄像头视频显示正常

gst-launch v4l2src !video/x-raw-yuv,format=\(fourcc\)YUY2,width=640,height=480,framerate=15/1 !videorate ! videoscale ! ffmpegcolorspace ! xvimagesink

gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=15/1 !queue2 ! videorate ! videoscale ! ffmpegcolorspace ! xvimagesink

三、摄像头视频现实及保存为avi格式文件

gst-launch -e v4l2src !video/x-raw-yuv,format=\(fourcc\)YUY2,width=640,height=480,framerate=30/1 ! teename=srctee \

srctee. ! queue2 name=squeue ! ffmpegcolorspace ! xvimagesink \

srctee. ! queue2 name=fqueue !  videorate ! ffmpegcolorspace !ffenc_mpeg4 ! avimux ! filesink location=test.avi

四、将摄像头视频比例设置为16:9

gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=15/1 !aspectratiocrop aspect-ratio=16/9 ! ffmpegcolorspace ! xvimagesink

五、保存摄像头的视频为avi格式

gst-launch -e v4l2src ! video/x-raw-yuv, format=\(fourcc\)YUY2,framerate=30/1, width=640, height=480 ! videorate ! ffmpegcolorspace !ffenc_mpeg4 ! avimux ! filesink location=test.avi

六、多个流数据同时录制

gst-launch -e avimux name="muxer" ! filesink location=multi.avi\

v4l2src ! video/x-raw-yuv, format=\(fourcc\)YUY2, framerate=25/1,width=640, height=480 ! videorate ! ffmpegcolorspace ! ffenc_mpeg4 ! queue2 !muxer. \

pulsesrc ! audioconvert ! audioresample! lamemp3enc target=1 bitrate=64cbr=true ! queue2 ! muxer.

七、画中画

1、videomixer可以将两个或多个视频流混合到一起:

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! videomixer name=mix ! \

ffmpegcolorspace ! xvimagesink videotestsrc !video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.

2、GstVideoMixerPad能够改变Z轴和图像的位置

gst-launch videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! \

videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100sink_2::zorder=2 ! \

ffmpegcolorspace ! xvimagesink videotestsrc pattern=13 !video/x-raw-yuv, framerate=10/1, width=200, height=150 ! mix. \

videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640,height=360 ! mix.

3、GstVideoMixerPad可以制定每个sink

gst-launch \

videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2! \

ffmpegcolorspace ! xvimagesink \

videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640,height=360 ! mix.sink_0 \

videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! mix.sink_1 \

videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1,width=200, height=150 ! mix.sink_2

八、VideoBox可以用来制定视频框的大小和位置和apha混合透明度等

1、不透明

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! videobox border-alpha=0 top=-100left=-100 ! \

videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc !video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.

2、指定透明度

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! \

videobox border-alpha=0 alpha=0.6 top=-20 left=-25 !videomixer name=mix ! ffmpegcolorspace ! xvimagesink \

videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640,height=360 ! mix.

3、添加边框

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! \

videobox border-alpha=1.0 top=-2 bottom=-2 left=-2 right=-2 !videobox border-alpha=0 alpha=0.6 top=-20 left=-25 ! \

videomixer name=mix ! ffmpegcolorspace ! xvimagesinkvideotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.

九、VideoWall视频墙

gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \

videotestsrc pattern=1 ! video/x-raw-yuv, framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. \

videotestsrc pattern=15 ! video/x-raw-yuv, framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. \

videotestsrc pattern=13 ! video/x-raw-yuv, framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. \

videotestsrc pattern=0 ! video/x-raw-yuv, framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. \

videotestsrc pattern=3 ! video/x-raw-yuv, framerate=5/1,width=640, height=360 ! mix.

十、TextOverlay 在视频上面添加文本,由textoverlay插件实现,可以设置文本的属性

gst-launch videotestsrc !video/x-raw-yuv,width=640,height=480,framerate=15/1 ! textoverlaytext="Hello" ! ffmpegcolorspace ! ximagesink

十一、TimeOverlay ,由timeoverlay插件实现

1、由timeoverlay插件实现

gst-launch videotestsrc ! timeoverlay ! xvimagesink

gst-launch -v videotestsrc ! video/x-raw-yuv, framerate=25/1, width=640,height=360 ! \

timeoverlay halign=left valign=bottom text="Streamtime:" shaded-background=true ! xvimagesink

2、cairotimeoverlay

gst-launch videotestsrc ! cairotimeoverlay ! ffmpegcolorspace ! xvimagesink

3、clockoverlay时钟

gst-launch videotestsrc ! cairotimeoverlay ! ffmpegcolorspace ! xvimagesink

gst-launch videotestsrc ! clockoverlay halign=right valign=bottomshaded-background=true time-format="%Y.%m.%D" ! ffmpegcolorspace !ximagesink

十二、录制视频为ogg格式,带时间和日期overlay

gst-launch -e v4l2src ! video/x-raw-yuv, format=\(fourcc\)YUY2,framerate=20/1, width=640, height=480 ! \

ffmpegcolorspace ! \

timeoverlay halign=right valign=top ! clockoverlayhalign=left valign=top time-format="%Y/%m/%d %H:%M:%S" ! \

tee name="splitter" ! queue2 ! xvimagesinksync=false splitter. ! \

queue2 ! videorate ! ffmpegcolorspace ! theoraenc bitrate=256! oggmux ! filesink location=webcam.ogg

十三、视频墙

gst-launch videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=1.0 sink_1::zorder=3 sink_2::xpos=40 sink_2::ypos=40sink_2::zorder=2 ! ffmpegcolorspace ! xvimagesink \

uridecodebinuri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4 ! ffmpegcolorspace !videoscale ! mix. \

uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/davincieffect_480p30.mp4! ffmpegcolorspace ! videoscale ! mix. \

videotestsrc ! video/x-raw-yuv, framerate=10/1,width=800, height=540 ! mix.

十四、播放视频文件,带声音

gst-launch uridecodebinuri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4 name=decoder \

decoder. ! audioconvert ! autoaudiosink \

decoder. ! ffmpegcolorspace ! xvimagesink

【视频开发】Gstreamer中一些gst-launch常用命令的更多相关文章

  1. Linux 系统中如何查看日志 (常用命令) tail -f

    Linux 系统中如何查看日志 (常用命令)  tail -f 日志文件 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日 ...

  2. Redis中的数据结构与常用命令

    开发系统:Ubuntu 17.04Redis驱动:StackExchange.Redis 1.2.3Redis版本:3.2.1开发平台:.NET Core 对于Redis的介绍这里只写一句:Redis ...

  3. linux系统中日常运维常用命令汇总一

    一.查看日志和机器相关信息常用命令 1.cat cat 命令连接文件并打印到标准输出设备上,cat经常用来显示文件的内容,类似于下的type命令注意:当文件较大时,文本在屏幕上迅速闪过(滚屏),用户往 ...

  4. 【入门】Gradle的基本使用、在IDEA中的配置、常用命令

    一.介绍 java的源码构建工具,大致经历了 ant -> maven -> gradle 这个过程,每一次进步,都是在解决之前的工具所带来的问题,简单来说: 1. ant 功能虽然也很强 ...

  5. linux系统中如何查看日志 (常用命令2)

    cat tail -f 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安全相关 ...

  6. linux系统中如何查看日志 (常用命令)

    cat tail -f 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安全相关 ...

  7. 【开发工具 - Git】之Git常用命令汇总

    本文记录了Git Bash中的常用指令. 1       Git操作 git clone XXXXX:将GitHub项目XXXXX克隆到本地 git remote –v:查看远程连接信息 git ch ...

  8. Centos中查看系统信息的常用命令

    系统日志文件(可以通过cat或tail命令来查看) /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 /var/log/secure 与安全 ...

  9. Linux中,MySQL的常用命令

    我的博客 登录 mysql -u用户名 -p -- 然后在下面输入密码,Linux的密码不会显示出,盲打就可以 mysql -u用户名 -p密码 -- 这种方式将直接登录 开关 开启数据库 servi ...

  10. 夺命雷公狗---node.js---2node.js中的npm的常用命令

    npm install <name> 安装nodejs的依赖包 例如npm install express 就会默认安装express的最新版本,也可以通过在后面加版本号的方式安装指定版本 ...

随机推荐

  1. 33、安装MySQL

    一.Windows安装MySQL 1.下载 打开网址,页面如下,确认好要下载的操作系统,点击Download. 可以不用登陆或者注册,直接点击No thanks,just start my downl ...

  2. 没有内置小鹤双拼的rime输入法就是差劲

    没有内置小鹤双拼的rime输入法就是差劲,还特立独行,搞什么繁体~ 没有内置小鹤双拼的rime输入法就是差劲,还特立独行,搞什么繁体~ 没有内置小鹤双拼的rime输入法就是差劲,还特立独行,搞什么繁体 ...

  3. HDU 6595 Everything Is Generated In Equal Probability (期望dp,线性推导)

    Everything Is Generated In Equal Probability \[ Time Limit: 1000 ms\quad Memory Limit: 131072 kB \] ...

  4. Hibernate的批量查询——原生sql查询

    1.查询所有的学生信息: (1)查询结果中,一条信息放入到一个数组中,从list集合中取出数组,并对数组进行遍历. public class GeneratorTest { public static ...

  5. TCP三次握手的过程,accept发生在三次握手的哪一个阶段?

    答案是:accept过程发生在三次握手之后,三次握手完成后,客户端和服务器就建立了tcp连接并可以进行数据交互了.这时可以调用accept函数获得此连接. TCP Accept总结 TCP Accep ...

  6. bzoj3073: [Pa2011]Journeys 线段树优化建图

    bzoj3073: [Pa2011]Journeys 链接 BZOJ 思路 区间和区间连边.如何线段树优化建图. 和单点连区间类似的,我们新建一个点,区间->新点->区间. 又转化成了单点 ...

  7. 信息学奥赛一本通 提高篇 序列第k个数 及 快速幂

    我是传送门 这个题首先是先判断是等差还是等比数列 等差的话非常简单: 前后两个数是等差的,举个栗子: 3 6 9 12 这几个数,(我感觉 1 2 3 4并说明不了什么) 每次都加3嘛,很容易看出,第 ...

  8. 【题解】 洛谷 P2649 游戏预言

    题目: P2649 游戏预言 题意: John和他的好朋基友们在van纸牌游戏.共有\(m\)个人.纸牌有\(n \times m\)张,从\(1--n \times m\)编号.每人有\(n\)张. ...

  9. 【ARC098F】Donation

    [ARC098F]Donation 题面 atcoder 题意: 给定一张\(n\)个点,\(m\)条边的无向图.这张图的每个点有两个权值 \(a_i,b_i\). 你将会从这张图中选出一个点作为起点 ...

  10. nuxtjs在vue组件中使用window对象编译报错的解决方法

    我们知道nuxtjs是做服务端渲染的,他有很多声明周期是运行在服务端的,以及正常的vue声明周期mounted之前均是在服务端运行的,那么服务端是没有比如window对象的location.navag ...