-
Notifications
You must be signed in to change notification settings - Fork 95
/
playbin_into_fakesink.py
45 lines (33 loc) · 1.18 KB
/
playbin_into_fakesink.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
'''
This is an example of how to use Playbin, and send its output somewhere other
than local video/audio playback.
Using the 'video-sink' and 'audio-sink' properties, different ends of the Playbin
pipeline can be set.
Try experimenting with the 'DISABLE_VIDEO' and 'DISABLE_AUDIO' constants below.
When set to true, they allow the Playbin sink to be set to 'fakesink', which
stops them from playing locally.
'''
DISABLE_VIDEO=False
DISABLE_AUDIO=True
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
import os
Gst.init(None)
mainloop = GObject.MainLoop()
pipe1 = Gst.parse_launch("playbin uri=\"file://" + os.environ['SRC'] + "\"")
playsink = pipe1.get_by_name('playsink')
if DISABLE_VIDEO:
fakesink1 = Gst.ElementFactory.make("fakesink", "fakesink1")
playsink.set_property('video-sink', fakesink1)
if DISABLE_AUDIO:
fakesink2 = Gst.ElementFactory.make("fakesink", "fakesink2")
playsink.set_property('audio-sink', fakesink2)
pipe1.set_state(Gst.State.PLAYING)
def on_error(bus, message):
print(message.parse_error())
bus1 = pipe1.get_bus()
bus1.add_signal_watch()
bus1.connect('message::error', on_error)
mainloop.run()