home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-gst0.10 / examples / cp.py < prev    next >
Encoding:
Python Source  |  2006-07-31  |  1.9 KB  |  68 lines

  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., 59 Temple Place - Suite 330,
  22. # Boston, MA 02111-1307, USA.
  23. # Author: David I. Lehn <dlehn@users.sourceforge.net>
  24. #
  25.  
  26. import sys
  27.  
  28. import gst
  29.  
  30. def filter(input, output):
  31.    "A GStreamer copy pipeline which can add arbitrary filters"
  32.  
  33.    # create a new bin to hold the elements
  34.    bin = gst.parse_launch('filesrc name=source ! ' +
  35.                           'statistics silent=false buffer-update-freq=1 ' +
  36.                           'update_on_eos=true ! ' +
  37.                           'filesink name=sink')
  38.    filesrc = bin.get_by_name('source')
  39.    filesrc.set_property('location', input)
  40.  
  41.    filesink = bin.get_by_name('sink')
  42.    filesink.set_property('location', output)
  43.  
  44.    # start playing
  45.    bin.set_state(gst.STATE_PLAYING);
  46.  
  47.    try:
  48.       while bin.iterate():
  49.          pass
  50.    except KeyboardInterrupt:
  51.       pass
  52.  
  53.    # stop the bin
  54.    bin.set_state(gst.STATE_NULL)
  55.  
  56. def main(args):
  57.    "A GStreamer based cp(1) with stats"
  58.  
  59.    if len(args) != 3:
  60.       print 'usage: %s source dest' % (sys.argv[0])
  61.       return -1
  62.  
  63.    return filter(args[1], args[2])
  64.  
  65. if __name__ == '__main__':
  66.    sys.exit(main(sys.argv))
  67.