将gst启动命令转换为Python程序

将gst启动命令转换为Python程序,python,pipeline,gstreamer,gst-launch,Python,Pipeline,Gstreamer,Gst Launch,如何使用PyGST模块将以下gst-launch命令实现到Python程序中 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 ! \

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

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
您不能真正将“gst启动语法”转换为“python语法”

要么使用gst.element\u factory\u make()和friends“手动”(编程)创建相同的管道,然后自己链接所有内容

或者你只是使用一些类似于:

管道=gst.parse_启动(“v4l2src!”)

您可以为管道字符串中的元素命名,例如v4l2src name=mysrc。。。然后使用从管道中检索元素

src=pipeline.get\u by\u name('mysrc')

然后对其设置属性,如:


src.set_属性(“location”,filepath)

看看我对
gst
模块的包装:

注意,分支和muxing是通过仔细链接元素定义的。您的特定管道是:

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.')
来自gstwrap导入元素,管道
ee=(
#从src到水槽[0:5]
元素('v4l2src'),
元素('caps过滤器',[('caps','video/x-raw-yuv,帧速率=30/1,宽度=640,高度=360')),
元素('tee',[('name','t_vid')]),
元素('队列'),
元素('videoflip',[('method','horizontal flip')]),
元素('xImageSink',[('sync','false')]),
#分支1[6:9]
元素('队列'),
元素(“视频速率”),
元素('caps过滤器',[('caps','video/x-raw-yuv,帧速率=30/1')),
元素('队列'),
#第二分部[10:15]
元素('alsasrc'),
元素('caps过滤器',[('caps','audio/x-raw-int,rate=48000,channels=2,depth=16')),
元素('队列'),
元素('audioconvert'),
元素('队列'),
#木兴
元素('avimux',[('name','mux')]),
元素('filesink',[('location','me\u dancing\u funcy.avi')),
)
管道=管道()
对于范围内的索引(len(ee)):
管道添加(ee[索引])
ee[0]。链接(ee[1])
ee[1]。链接(ee[2])
ee[2]。链接(ee[3])
ee[3]。链接(ee[4])
ee[4]。链接(ee[5])
#分支机构1
ee[2]。链接(ee[6])
ee[6]。链接(ee[7])
ee[7]。链接(ee[8])
ee[8]。链接(ee[9])
#分支机构2
ee[10]。链接(ee[11])
ee[11]。链接(ee[12])
ee[12]。链接(ee[13])
ee[13]。链接(ee[14])
ee[14]。链接(ee[15])
#木兴
ee[9]。链接(ee[15])
ee[15]。链接(ee[16])
打印(管道)
pipe.start()
原始输入(“点击停止”)

感谢Tim的回复,但我正在寻找相同的,即编程转换(不使用任何工具)。