tuxmartin

gstreamer - caps modify

Aug 5th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 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. pipeline.set_state(Gst.State.PLAYING)
  13.  
  14. aaa = pipeline.get_by_name('mycapsfilter')
  15.  
  16. while True:
  17. print "+ [1], - [2], end [0]"
  18. x = raw_input()
  19.  
  20. if x=='0':
  21. print "END"
  22. bus = pipeline.get_bus()
  23. bus.add_signal_watch()
  24. pipeline.send_event(Gst.Event.new_eos())
  25. msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)
  26. pipeline.set_state(Gst.State.NULL)
  27. sys.exit()
  28.  
  29. elif x=='1':
  30. print "+"
  31. aaa.set_property("caps", 'video/x-raw,width=1280,height=720')
  32.  
  33. elif x=='2':
  34. print "-"
  35. aaa.set_property("caps", 'video/x-raw,width=320,height=240')
  36.  
  37.  
  38. else:
  39. print "wtf"
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. /usr/bin/python2.7 /home/martin/PycharmProjects/gstreamer/e.py
  50. + [1], - [2], end [0]
  51. 1
  52. +
  53. Traceback (most recent call last):
  54. File "/home/martin/PycharmProjects/gstreamer/e.py", line 31, in <module>
  55. aaa.set_property("caps", 'video/x-raw,width=1280,height=720')
  56. TypeError: could not convert 'video/x-raw,width=1280,height=720' to type 'GstCaps' when setting property 'GstCapsFilter.caps'
  57.  
  58. Process finished with exit code 1
Add Comment
Please, Sign In to add comment