gstreamer/examples/gst/cp.py
Thomas Vander Stichele d13b976ed2 make examples use Element
Original commit message from CVS:
make examples use Element
2003-10-04 23:02:48 +00:00

84 lines
2.2 KiB
Python
Executable file

#!/usr/bin/env python
#
# gst-python
# Copyright (C) 2002 David I. Lehn
#
# 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.
#
# Author: David I. Lehn <dlehn@users.sourceforge.net>
#
import sys
from gstreamer import *
from gobject import GObject
def update(sender, *args):
print sender.get_name(), args
def filter(filters):
"A GStreamer copy pipeline which can add arbitrary filters"
if len(sys.argv) != 3:
print 'usage: %s source dest' % (sys.argv[0])
return -1
# create a new bin to hold the elements
bin = Pipeline('pipeline')
filesrc = Element('filesrc', 'source');
filesrc.set_property('location', sys.argv[1])
filesink = Element('filesink', 'sink')
filesink.set_property('location', sys.argv[2])
elements = [filesrc] + filters + [filesink]
# add objects to the main pipeline
for e in elements:
bin.add(e)
# link the elements
previous = None
for e in elements:
if previous:
previous.link(e)
previous = e
# start playing
bin.set_state(STATE_PLAYING);
while bin.iterate(): pass
# stop the bin
bin.set_state(STATE_NULL)
return 0
def main():
"A GStreamer based cp(1) with stats"
#gst_info_set_categories(-1)
#gst_debug_set_categories(-1)
stats = Element ('statistics', 'stats');
stats.set_property('silent', 0)
stats.set_property('buffer_update_freq', 1)
stats.set_property('update_on_eos', 1)
#stats.connect('update', update)
return filter([stats])
if __name__ == '__main__':
ret = main()
sys.exit (ret)