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