mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 19:50:40 +00:00
15f1eb48cf
Original commit message from CVS: * gst/gstmodule.c (init_gst): Add constants for GST_*SECOND. (python_do_pending_calls): New idler handler, similar to pygtk, so python events (eg KeyboardInterrupt) can be raised during mainloop * gst/gst.override (_wrap_gst_bin_get_list): (_wrap_gst_pad_tp_repr, caps_length, caps_item) (structure_length, structure_subscript) (_wrap_gst_structure_tp_repr): Impl. (_wrap_gst_main): Override with threading blocking. * gst/gst-types.defs (Object): add flags field. (Structure): Add copy/release funcs * gst/__init__.py (devloc): Don't initialize threads * gst/Makefile.am: clean up * examples/gst/player.py: Prettify and simplify. Uses GstThread now. * examples/gstplay/player.py: Update to new api and make it work.
68 lines
2.1 KiB
Python
Executable file
68 lines
2.1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# Copyright (C) 2004 David I. Lehn
|
|
# 2004 Johan Dahlin
|
|
#
|
|
# 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.
|
|
|
|
import sys
|
|
import gst
|
|
import gst.play
|
|
|
|
def nano2str(nanos):
|
|
ts = nanos / gst.SECOND
|
|
return '%02d:%02d:%02d.%06d' % (ts / 3600,
|
|
ts / 60,
|
|
ts % 60,
|
|
nanos % gst.SECOND)
|
|
|
|
def stream_length_cb(play, ns):
|
|
print 'stream length: %s' % nano2str(ns)
|
|
|
|
def have_video_size_cb(play, w, h):
|
|
print 'video size %d %d' % (w, h)
|
|
|
|
def found_tag_cb(play, src, tags):
|
|
for tag in tags.keys():
|
|
print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])
|
|
|
|
def main(args):
|
|
if len(args) != 2:
|
|
print 'Usage: %s file' % args[0]
|
|
return -1
|
|
|
|
filename = args[1]
|
|
|
|
play = gst.play.Play()
|
|
play.connect('stream-length', stream_length_cb)
|
|
play.connect('have-video-size', have_video_size_cb)
|
|
play.connect('found-tag', found_tag_cb)
|
|
play.connect('eos', lambda p: gst.main_quit())
|
|
|
|
# Setup source and sinks
|
|
play.set_data_src(gst.Element('filesrc'))
|
|
play.set_audio_sink(gst.Element('osssink'))
|
|
play.set_video_sink(gst.Element('fakesink'))
|
|
|
|
# Point location to our filename
|
|
play.set_location(filename)
|
|
|
|
# Start playing the stream
|
|
play.set_state(gst.STATE_PLAYING)
|
|
gst.main()
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv))
|