qtdemux: Don't emit GstSegment correcting start time when in MSE mode
[platform/upstream/gstreamer.git] / subprojects / gst-python / old_examples / cp.py
1 #!/usr/bin/env python
2 # -*- Mode: Python -*-
3 # vi:si:et:sw=4:sts=4:ts=4
4
5 # gst-python
6 # Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
7 #               2004 Johan Dahlin  <johan@gnome.org>
8 #
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Library General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Library General Public License for more details.
18 #
19 # You should have received a copy of the GNU Library General Public
20 # License along with this library; if not, write to the
21 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
23
24 # Author: David I. Lehn <dlehn@users.sourceforge.net>
25 #
26
27 import sys
28
29 import gobject
30 gobject.threads_init()
31
32 import pygst
33 pygst.require('0.10')
34 import gst
35
36
37 mainloop = gobject.MainLoop()
38
39 def on_eos(bus, msg):
40    mainloop.quit()
41
42 def filter(input, output):
43    "A GStreamer copy pipeline which can add arbitrary filters"
44
45    # create a new bin to hold the elements
46    bin = gst.parse_launch('filesrc name=source ! ' +
47                           'progressreport ! ' +
48                            # This 'statistics' element is depreciated in 0.10
49                           #'statistics silent=false buffer-update-freq=1 ' +
50                           #'update_on_eos=true ! ' +
51                           'filesink name=sink')
52    filesrc = bin.get_by_name('source')
53    filesrc.set_property('location', input)
54
55    filesink = bin.get_by_name('sink')
56    filesink.set_property('location', output)
57
58    bus = bin.get_bus()
59    bus.add_signal_watch()
60    bus.connect('message::eos', on_eos)
61
62    # start playing
63    bin.set_state(gst.STATE_PLAYING)
64
65    try:
66       mainloop.run()
67    except KeyboardInterrupt:
68       pass
69
70    # stop the bin
71    bin.set_state(gst.STATE_NULL)
72
73 def main(args):
74    "A GStreamer based cp(1) with stats"
75
76    if len(args) != 3:
77       print 'usage: %s source dest' % (sys.argv[0])
78       return -1
79
80    return filter(args[1], args[2])
81
82 if __name__ == '__main__':
83    sys.exit(main(sys.argv))