#!/usr/bin/env python3 # -*- coding:utf-8 -*- import sys import gi gi.require_version('Gst', '1.0') from gi.repository import Gst Gst.init(None) pipeline = Gst.parse_launch("v4l2src device=/dev/video0 ! capsfilter name=mycapsfilter caps=video/x-raw,width=1280,height=720 ! x264enc tune=zerolatency ! mp4mux ! filesink location=/tmp/file.mp4") pipeline.set_state(Gst.State.PLAYING) aaa = pipeline.get_by_name('mycapsfilter') while True: print "+ [1], - [2], end [0]" x = raw_input() if x=='0': print "END" bus = pipeline.get_bus() bus.add_signal_watch() pipeline.send_event(Gst.Event.new_eos()) msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS) pipeline.set_state(Gst.State.NULL) sys.exit() elif x=='1': print "+" aaa.set_property("caps", 'video/x-raw,width=1280,height=720') elif x=='2': print "-" aaa.set_property("caps", 'video/x-raw,width=320,height=240') else: print "wtf" /usr/bin/python2.7 /home/martin/PycharmProjects/gstreamer/e.py + [1], - [2], end [0] 1 + Traceback (most recent call last): File "/home/martin/PycharmProjects/gstreamer/e.py", line 31, in aaa.set_property("caps", 'video/x-raw,width=1280,height=720') TypeError: could not convert 'video/x-raw,width=1280,height=720' to type 'GstCaps' when setting property 'GstCapsFilter.caps' Process finished with exit code 1