2011-08-02 15 views
3

PyGST 모듈을 사용하여 다음 gst-launch 명령을 Python 프로그램에 구현하려면 어떻게해야합니까?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 

답변

2

"gst-launch syntax"를 "python syntax"로 변환 할 수 없습니다.

gst.element_factory_make()와 친구들을 사용하여 '수동으로'(프로그래밍 방식으로) 동일한 파이프 라인을 만들고 모두 직접 연결하십시오.

또는 당신은 같은 것을 사용

파이프 라인 = gst.parse_launch ("! v4l2src .....")

당신은 예를 들어, 귀하의 파이프 라인 문자열 이름의 요소를 제공 할 수 있습니다 v4l2src 이름 = mysrc! ... 그리고 다음에

다음 속성을 설정 좋아

SRC = pipeline.get_by_name ('mysrc')와 파이프 라인에서 요소를 검색 :

src.set_property ("위치" , 분기 및 멀티플렉싱이 요소의주의 연결에 의해 정의된다 https://github.com/vmlaker/gstwrap

참고 : 파일 경로)

+0

감사합니다. Tim이 (가) 응답을했지만 프로그램 식 변환 (도구를 사용하지 않음)을 찾고있었습니다. – Yajushi

0

gst 모듈의 내 래퍼를 살펴 보자. 귀하의 특정 파이프 라인은 다음과 같습니다.

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.') 
관련 문제