Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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 ! 'video/x-raw,format=YUY2,width=320,height=240' ! x264enc tune=zerolatency ! mp4mux ! filesink location=/tmp/file.mp4")
- pipeline = Gst.parse_launch("v4l2src device=/dev/video0 ! x264enc name=X tune=zerolatency ! mp4mux ! filesink location=/tmp/file.mp4")
- # Start playing
- pipeline.set_state(Gst.State.PLAYING)
- applyFilter = pipeline.get_by_name('X')
- 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 "+"
- caps1 = Gst.Caps.from_string("video/x-raw,width=1280,height=720")
- capsFilter1 = Gst.ElementFactory.make("capsfilter", "filter1")
- capsFilter1.set_property("caps", caps1)
- #pipeline.add(capsFilter1)
- applyFilter.add(capsFilter1)
- elif x=='2':
- print "-"
- caps2 = Gst.Caps.from_string("video/x-raw,width=320,height=240")
- capsFilter2 = Gst.ElementFactory.make("capsfilter", "filter2")
- capsFilter2.set_property("caps", caps2)
- #pipeline.add(capsFilter2)
- applyFilter.add(capsFilter2)
- else:
- print "wtf"
Add Comment
Please, Sign In to add comment