4 # A replacement for gst-launch that allows seeks
7 gst-launch with goodies
9 It allows to seek in the pipeline.
15 from optparse
import OptionParser
17 parser = OptionParser(version=
'%prog 1.0', usage=
'%prog [options]',
20 parser.add_option('--start', type='
int', help='start time')
21 parser.add_option('--end', type='
int', help='end time')
23 opts, rest = parser.parse_args()
35 from gstlal
import simplehandler
39 # Create the pipeline (yes, it's *that* easy)
42 mainloop = gobject.MainLoop()
43 pipeline = gst.parse_launch(
' '.join(rest))
47 # Make it start playing at the appropriate time
50 if opts.start is not None:
51 start_seektype = gst.SEEK_TYPE_SET
52 start_ns = opts.start * 1e9
54 start_seektype = gst.SEEK_TYPE_NONE
55 start_ns = 0 # not used anyway
57 if opts.end is not None:
58 end_seektype = gst.SEEK_TYPE_SET
59 end_ns = opts.end * 1e9
61 end_seektype = gst.SEEK_TYPE_NONE
62 end_ns = 0 # not used anyway
64 for src in pipeline.iterate_sources():
65 src.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH,
66 start_seektype, start_ns,
74 handler = simplehandler.Handler(mainloop, pipeline)
75 if pipeline.set_state(gst.STATE_PLAYING) == gst.STATE_CHANGE_FAILURE:
76 raise RuntimeError(
"pipeline failed to enter PLAYING state")