sample_gst1_python.py 587 B

123456789101112131415161718192021
  1. #!/usr/bin/env python
  2. """A simple test that uses gst1-python to run a fake videotestsrc for 100 frames"""
  3. import sys
  4. import gi
  5. import time
  6. gi.require_version('Gst', '1.0')
  7. from gi.repository import Gst, GLib
  8. def main():
  9. # Initializes Gstreamer
  10. Gst.init(sys.argv)
  11. pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! autovideosink")
  12. bus = pipeline.get_bus()
  13. bus.add_signal_watch()
  14. pipeline.set_state(Gst.State.PLAYING)
  15. loop = GLib.MainLoop()
  16. bus.connect("message", on_message, loop)
  17. loop.run()
  18. pipeline.set_state(Gst.State.EOS)
  19. exit(0)