tuxmartin

Untitled

Jul 29th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 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 ! capsfilter name=mycapsfilter caps=video/x-raw,width=1280,height=720 ! x264enc tune=zerolatency ! mp4mux ! filesink location=/tmp/file.mp4")
  11.  
  12. # Start playing
  13. pipeline.set_state(Gst.State.PLAYING)
  14.  
  15. aaa = pipeline.get_by_name('mycapsfilter')
  16.  
  17. while True:
  18.     print "+ [1], - [2], end [0]"
  19.     x = raw_input()
  20.  
  21.     if x=='0':
  22.         print "END"
  23.         bus = pipeline.get_bus()
  24.         bus.add_signal_watch()
  25.         pipeline.send_event(Gst.Event.new_eos())-
  26.         msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)
  27.         pipeline.set_state(Gst.State.NULL)
  28.         sys.exit()
  29.  
  30.     elif x=='1':
  31.         print "+"
  32.         aaa.set_property("caps", 'video/x-raw,width=1280,height=720')
  33.  
  34.     elif x=='2':
  35.         print "-"
  36.         aaa.set_property("caps", 'video/x-raw,width=320,height=240')
  37.  
  38.     elif x=='4':
  39.         print"RESOLUTION +"
  40.  
  41.     else:
  42.         print "wtf"
Advertisement
Add Comment
Please, Sign In to add comment