2 # This is a reworked version of the example from Jono Bacon's Python+Gstreamer
3 # primer: http://www.jonobacon.org/2006/08/28/getting-started-with-gstreamer-with-python/
5 # It uses Gstreamer 1.0, and replaces alsa with pulse for audio output, and
6 # drops the use of the GTK main loop, since we're not bothered with a GUI
7 # Info on porting python scripts to Gstreamer 1.0 can be found here:
8 # https://wiki.ubuntu.com/Novacut/GStreamer1.0
10 from gi
.repository
import Gst
, GObject
14 # Initiate the pipeline
16 self
.pipeline
= Gst
.Pipeline("mypipeline")
18 # Add an audiotestsrc element to the pipeline
19 self
.audiotestsrc
= Gst
.ElementFactory
.make("audiotestsrc", "audio")
20 self
.pipeline
.add(self
.audiotestsrc
)
22 # Add a pulsesink element to the pipeline
23 self
.pulsesink
= Gst
.ElementFactory
.make("pulsesink", "sink")
24 self
.pipeline
.add(self
.pulsesink
)
26 # Link the two elements together
27 self
.audiotestsrc
.link(self
.pulsesink
)
29 # Set the pipeline to the playing state
30 self
.pipeline
.set_state(Gst
.State
.PLAYING
)
32 # Create the pipelie and enter main loop, quit with ctrl+c
34 mainloop
= GObject
.MainLoop()