tuxmartin

gstreamer - caps filter 1

Jul 29th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding:utf-8 -*-
  3.  
  4. import sys
  5. import gi
  6. gi.require_version('Gst', '1.0')
  7. from gi.repository import Gst
  8. Gst.init(None)
  9.  
  10. #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")
  11. pipeline = Gst.parse_launch("v4l2src device=/dev/video0 ! x264enc name=X tune=zerolatency ! mp4mux ! filesink location=/tmp/file.mp4")
  12.  
  13. # Start playing
  14. pipeline.set_state(Gst.State.PLAYING)
  15.  
  16. applyFilter = pipeline.get_by_name('X')
  17.  
  18. while True:
  19.     print "+ [1], - [2], end [0]"
  20.     x = raw_input()
  21.  
  22.     if x=='0':
  23.         print "END"
  24.         bus = pipeline.get_bus()
  25.         bus.add_signal_watch()
  26.         pipeline.send_event(Gst.Event.new_eos())
  27.         msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)
  28.         pipeline.set_state(Gst.State.NULL)
  29.         sys.exit()
  30.  
  31.     elif x=='1':
  32.         print "+"
  33.         caps1 = Gst.Caps.from_string("video/x-raw,width=1280,height=720")
  34.         capsFilter1 = Gst.ElementFactory.make("capsfilter", "filter1")
  35.         capsFilter1.set_property("caps", caps1)
  36.         #pipeline.add(capsFilter1)
  37.         applyFilter.add(capsFilter1)
  38.  
  39.     elif x=='2':
  40.         print "-"
  41.         caps2 = Gst.Caps.from_string("video/x-raw,width=320,height=240")
  42.         capsFilter2 = Gst.ElementFactory.make("capsfilter", "filter2")
  43.         capsFilter2.set_property("caps", caps2)
  44.         #pipeline.add(capsFilter2)
  45.         applyFilter.add(capsFilter2)
  46.  
  47.     else:
  48.         print "wtf"
Add Comment
Please, Sign In to add comment