Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert gst-launch command to Python program

How do I implement the following gst-launch command into a Python program using the PyGST module?

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
like image 232
Yajushi Avatar asked Mar 16 '26 19:03

Yajushi


1 Answers

You can't really convert "gst-launch syntax" to "python syntax".

Either you create the same pipeline 'manually' (programmatically) using gst.element_factory_make() and friends, and link everything yourself.

Or you just use something like:

pipeline = gst.parse_launch ("v4l2src ! ..... ")

You can give elements in your pipeline string names with e.g. v4l2src name=mysrc ! ... and then retrieve the element from the pipeline with

src = pipeline.get_by_name ('mysrc')

and then set properties on it like:

src.set_property("location", filepath)

like image 115
Tim Avatar answered Mar 19 '26 09:03

Tim