gstlal 1.13.0
Loading...
Searching...
No Matches
gstlal_launch
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3
5
6"""
7gst-launch with goodies
8
9It allows to seek in the pipeline.
10"""
11
12# JBC. April 2011.
13
14import sys
15from optparse import OptionParser
16
17parser = OptionParser(version='%prog 1.0', usage='%prog [options]',
18 description=__doc__)
19
20parser.add_option('--start', type='int', help='start time')
21parser.add_option('--end', type='int', help='end time')
22
23opts, rest = parser.parse_args()
24
25
26#
27# Initialization
28#
29
30import gi
31gi.require_version('Gst', '1.0')
32from gi.repository import GObject, Gst
33GObject.threads_init()
34Gst.init(None)
35from gstlal import simplehandler
36
37
38#
39# Create the pipeline (yes, it's *that* easy)
40#
41
42mainloop = GObject.MainLoop()
43pipeline = Gst.parse_launch(' '.join(rest))
44
45
46#
47# Make it start playing at the appropriate time
48#
49
50if opts.start is not None:
51 start_seektype = Gst.SeekType.SET
52 start_ns = opts.start * 1e9
53else:
54 start_seektype = Gst.SeekType.NONE
55 start_ns = 0 # not used anyway
56
57if opts.end is not None:
58 end_seektype = Gst.SeekType.SET
59 end_ns = opts.end * 1e9
60else:
61 end_seektype = Gst.SeekType.NONE
62 end_ns = 0 # not used anyway
63
64for src in pipeline.iterate_sources():
65 src.seek(1.0, Gst.Format.TIME, Gst.SeekFlags.FLUSH,
66 start_seektype, start_ns,
67 end_seektype, end_ns)
68
69
70#
71# Boilerplate
72#
73
74handler = simplehandler.Handler(mainloop, pipeline)
75if pipeline.set_state(Gst.State.PLAYING) == Gst.StateChangeReturn.FAILURE:
76 raise RuntimeError("pipeline failed to enter PLAYING state")
77mainloop.run()