gst-inspect 与gst-launch

来源:互联网 发布:2016cpi数据 编辑:程序博客网 时间:2024/05/24 07:10
用gstreamer架构做对媒体开发时,gst-inspect 和gst-launch是两个非常使用的小工具,前者是用于查询库中已经包含的所有element以及他们的详细信息,后者用于快速构建一条pipeline,这个命令最爽,因为只要一句话,你就可以感受到播放的快感。废话不多说,直接看示例:

1 gst-inspect用法:

首先进入命令行下,然后键入:

gst-inspect, 所有element都显示;

gst-inspect >d:/c.txt 将所有element都导出到d盘根目录下的c。txt文件中,这个命令在你想要查找某个element但有不确定其全名时很有用

gst-inspect ffmpeg >d/c.txt 同上,只是导出的element范围缩小到ffmpeg范围内

gst-inspect ffdec_h264 . 显示ffdec-h264的详细信息,你可以输入想要查询的任何element,只要已经存在,就可以找到

 

2 gst-launch 构建链路用法:

最开始要构建链路,当然用playbin、playbin2,decodebin, decodebin2,uridecodebin这类上层的element是最简单省事的了。

比如,你想播放一个flv文件,位于d:/test_videos/1.flv,首先进入命令行下,然后键入:

gst-launch filesrc location=d:/test_videos/1.flv !decodebin !autovideosink         利用了filesrc decodebin 和autovideosink 3个element,其中设置了filesrc的location属性值为文件路径
gst-launch filesrc location=d:/test_videos/1.flv !decodebin2 !autovideosink       同上,只是decodebin用较新的decodebin2代替了

gst-launch uridecodebin uri=file:///d:/test_videos/1.flv !autovideosink        用uridecodebin 和autovideosink 2个element, 其中uridecodebin的属性uri设置了

gst-launch playbin uri=file:///d:test_video/1.flv               利用playbin一个element,设置了其属性uri 为file:///加文件路径
gst-launch playbin2 uri=file:///d:test_video/1.flv             同上,只是用较新的playbin2代替了playbin

 

如果想要自己用基本element而不用上层bin element 进行链路构建,那需要以下步骤。

比如, 你想播放一个flv文件,位于d:/test_videos/0.flv

首先你需要确定需要什么样的解码element来构建,所以,你首先需要确定该文件编码格式是什么,假如为h264

然后,在命令行下键入:

gst-launch filesrc location=d:/test_videos/0.flv !flvdemux !ffdec_h264 !autovideosink

其中,flvdemux用来分离多路数据的, ffdec-h264用来解码,最后由autovideosink播放

如果你想播放其他文件,只需要根据相应文件容器格式指定特定的demux,再根据编码格式指定特定的解码器便可以了,如果不清楚改用哪个element,最好的方法当然用是gst-inspect去查找和验证了
0 0
原创粉丝点击