2021-09-21 23:04:37 +02:00
|
|
|
#!/usr/bin/env python3
|
2020-03-24 18:38:53 +01:00
|
|
|
"""A simple test that uses gst1-python to run a fake videotestsrc for 100
|
|
|
|
frames
|
|
|
|
"""
|
2020-03-15 21:10:33 +01:00
|
|
|
import sys
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gst', '1.0')
|
2020-03-24 15:45:42 +01:00
|
|
|
from gi.repository import Gst, GLib # noqa: E402
|
2020-03-15 21:10:33 +01:00
|
|
|
|
|
|
|
|
2020-03-28 22:26:50 +01:00
|
|
|
def on_message(bus, message, loop):
|
2020-03-24 18:38:53 +01:00
|
|
|
print('Received Gst.Message.type: {}'.format(message.type))
|
|
|
|
if message.type == Gst.MessageType.EOS:
|
|
|
|
loop.quit()
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-03-15 21:10:33 +01:00
|
|
|
def main():
|
|
|
|
# Initializes Gstreamer
|
|
|
|
Gst.init(sys.argv)
|
2020-03-24 18:38:53 +01:00
|
|
|
pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! fakevideosink")
|
2020-03-15 21:10:33 +01:00
|
|
|
bus = pipeline.get_bus()
|
|
|
|
bus.add_signal_watch()
|
|
|
|
pipeline.set_state(Gst.State.PLAYING)
|
|
|
|
loop = GLib.MainLoop()
|
|
|
|
bus.connect("message", on_message, loop)
|
|
|
|
loop.run()
|
2020-03-24 18:38:53 +01:00
|
|
|
pipeline.set_state(Gst.State.NULL)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|