首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将gst-launch命令转换为Python程序

将gst-launch命令转换为Python程序
EN

Stack Overflow用户
提问于 2011-08-02 20:18:13
回答 2查看 3.2K关注 0票数 3

如何使用PyGST模块将以下gst-launch命令实现到Python程序中?

代码语言:javascript
复制
gst-launch-0.10 v4l2src ! \
'video/x-raw-yuv,width=640,height=480,framerate=30/1' ! \
tee name=t_vid ! \
   queue ! \
   videoflip method=horizontal-flip ! \
   xvimagesink sync=false \
t_vid. ! \
   queue ! \
   videorate ! \
   'video/x-raw-yuv,framerate=30/1' \
   ! queue ! \
mux. \
   alsasrc ! \
   audio/x-raw-int,rate=48000,channels=2,depth=16 ! \
   queue ! \
   audioconvert ! \
   queue ! \
mux. avimux name=mux ! \
   filesink location=me_dancing_funny.avi
EN

回答 2

Stack Overflow用户

发布于 2011-08-04 22:29:35

你不能真的把"gst-launch语法“转换成"python语法”。

要么使用gst.element_factory_make()和朋友‘手动’(以编程方式)创建相同的管道,然后自己链接所有内容。

或者你可以简单地使用下面这样的东西:

管道= gst.parse_launch ("v4l2src!..... ")

您可以为管道中的元素指定字符串名称,例如v4l2src name=mysrc!...,然后从管道中检索元素。

src = pipeline.get_by_name ('mysrc')

然后在其上设置属性,如下所示:

src.set_property("location",文件路径)

票数 2
EN

Stack Overflow用户

发布于 2015-05-15 01:35:57

看一下我的gst模块包装器:https://github.com/vmlaker/gstwrap

注分支和多路复用是通过仔细链接元素来定义的。然后,您的特定管道是:

代码语言:javascript
复制
from gstwrap import Element, Pipeline

ee = (

    # From src to sink [0:5]
    Element('v4l2src'),
    Element('capsfilter', [('caps','video/x-raw-yuv,framerate=30/1,width=640,height=360')]),
    Element('tee', [('name', 't_vid')]),
    Element('queue'),
    Element('videoflip', [('method', 'horizontal-flip')]),
    Element('xvimagesink', [('sync', 'false')]),

    # Branch 1 [6:9]
    Element('queue'),
    Element('videorate'),
    Element('capsfilter', [('caps', 'video/x-raw-yuv,framerate=30/1')]),
    Element('queue'),

    # Branch 2 [10:15]
    Element('alsasrc'),
    Element('capsfilter', [('caps', 'audio/x-raw-int,rate=48000,channels=2,depth=16')]),
    Element('queue'),
    Element('audioconvert'),
    Element('queue'),

    # Muxing
    Element('avimux', [('name', 'mux')]),
    Element('filesink', [('location', 'me_dancing_funny.avi')]),
)

pipe = Pipeline()
for index in range(len(ee)):
    pipe.add(ee[index])

ee[0].link(ee[1])
ee[1].link(ee[2])
ee[2].link(ee[3])
ee[3].link(ee[4])
ee[4].link(ee[5])

# Branch 1
ee[2].link(ee[6])
ee[6].link(ee[7])
ee[7].link(ee[8])
ee[8].link(ee[9])

# Branch 2
ee[10].link(ee[11])
ee[11].link(ee[12])
ee[12].link(ee[13])
ee[13].link(ee[14])
ee[14].link(ee[15])

# Muxing
ee[9].link(ee[15])
ee[15].link(ee[16])

print(pipe)
pipe.start()
raw_input('Hit <enter> to stop.')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6911954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档