2002-10-03 22:11:37 +00:00
|
|
|
#!/usr/bin/env python
|
2002-03-24 11:41:24 +00:00
|
|
|
#
|
|
|
|
# gst-python
|
2004-02-23 20:24:53 +00:00
|
|
|
# Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
|
|
|
|
# 2004 Johan Dahlin <johan@gnome.org>
|
2002-03-24 11:41:24 +00:00
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
#
|
2002-12-17 17:40:42 +00:00
|
|
|
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
2002-03-24 11:41:24 +00:00
|
|
|
#
|
2002-03-24 07:49:36 +00:00
|
|
|
|
2002-03-24 11:41:24 +00:00
|
|
|
import sys
|
2004-02-24 18:40:21 +00:00
|
|
|
|
2004-02-23 20:24:53 +00:00
|
|
|
import gst
|
2002-03-24 07:49:36 +00:00
|
|
|
|
2004-02-23 20:24:53 +00:00
|
|
|
def filter(input, output):
|
2002-03-27 11:09:40 +00:00
|
|
|
"A GStreamer copy pipeline which can add arbitrary filters"
|
2002-03-24 07:49:36 +00:00
|
|
|
|
|
|
|
# create a new bin to hold the elements
|
2004-10-11 09:55:44 +00:00
|
|
|
bin = gst.parse_launch('filesrc name=source ! ' +
|
|
|
|
'statistics silent=false buffer-update-freq=1 ' +
|
|
|
|
'update_on_eos=true ! ' +
|
|
|
|
'filesink name=sink')
|
|
|
|
filesrc = bin.get_by_name('source')
|
2004-02-23 20:24:53 +00:00
|
|
|
filesrc.set_property('location', input)
|
2002-03-24 07:49:36 +00:00
|
|
|
|
2004-10-11 09:55:44 +00:00
|
|
|
filesink = bin.get_by_name('sink')
|
2004-02-23 20:24:53 +00:00
|
|
|
filesink.set_property('location', output)
|
2002-03-24 07:49:36 +00:00
|
|
|
|
|
|
|
# start playing
|
2004-02-23 20:24:53 +00:00
|
|
|
bin.set_state(gst.STATE_PLAYING);
|
2002-03-24 07:49:36 +00:00
|
|
|
|
2004-10-11 09:55:44 +00:00
|
|
|
try:
|
|
|
|
while bin.iterate():
|
|
|
|
pass
|
|
|
|
except KeyboardInterrupt:
|
2004-02-23 20:24:53 +00:00
|
|
|
pass
|
2002-03-24 07:49:36 +00:00
|
|
|
|
|
|
|
# stop the bin
|
2004-02-23 20:24:53 +00:00
|
|
|
bin.set_state(gst.STATE_NULL)
|
2002-03-24 07:49:36 +00:00
|
|
|
|
2004-02-23 20:24:53 +00:00
|
|
|
def main(args):
|
2002-03-27 11:09:40 +00:00
|
|
|
"A GStreamer based cp(1) with stats"
|
|
|
|
|
2004-02-23 20:24:53 +00:00
|
|
|
if len(args) != 3:
|
|
|
|
print 'usage: %s source dest' % (sys.argv[0])
|
|
|
|
return -1
|
2002-03-27 11:09:40 +00:00
|
|
|
|
2004-02-23 20:24:53 +00:00
|
|
|
return filter(args[1], args[2])
|
2002-03-27 11:09:40 +00:00
|
|
|
|
2002-03-24 07:49:36 +00:00
|
|
|
if __name__ == '__main__':
|
2004-02-23 20:24:53 +00:00
|
|
|
sys.exit(main(sys.argv))
|