[gst-devel] python gstreamer
Fabien ROCHER
fabienrocher at gmail.com
Tue Aug 5 14:23:01 CEST 2008
Hello,
With this code, I can play a music file encode in vorbis and muxer in ogg.
Now I want to play a video in mpg. To do it, I want use the element playbin.
*#!/usr/bin/python
# import a buch of things
import pygst
pygst.require("0.10")
import gst
import pygtk
import gtk
import gtk.glade
# create a class and its constructor
class Main:
def __init__(self):
# set up the glade file
self.wTree = gtk.glade.XML("Gui_client.glade", "mainwindow")
signals = {
"on_play_clicked" : self.OnPlay,
"on_stop_clicked" : self.OnStop,
"on_quit_clicked" : self.OnQuit,
}
self.wTree.signal_autoconnect(signals)
# creating the pipeline
self.pipeline = gst.Pipeline("mypipeline")
# creating a gnlcomposition
self.comp = gst.element_factory_make("gnlcomposition",
"mycomposition")
self.pipeline.add(self.comp)
self.comp.connect("pad-added", self.OnPad)
# create an audioconvert
self.compconvert = gst.element_factory_make("audioconvert",
"compconvert")
self.pipeline.add(self.compconvert)
# create an alsasink
self.sink = gst.element_factory_make("alsasink", "alsasink")
self.pipeline.add(self.sink)
self.compconvert.link(self.sink)
# create a gnlfilesource
self.audio = gst.element_factory_make("gnlfilesource", "audio")
self.comp.add(self.audio)
# set the gnlfilesource properties
self.audio.set_property("location",
"/home/toto/Desktop/VoD/Sound.ogg")
self.audio.set_property("start", 10 * gst.SECOND)
self.audio.set_property("duration", 10000000 * gst.SECOND )
# show the window
self.window = self.wTree.get_widget("mainwindow")
self.window.show_all()
def OnPad(self, comp, pad):
print "pad added!"
convpad = self.compconvert.get_compatible_pad(pad, pad.get_caps())
pad.link(convpad)
def OnPlay(self, widget):
print "play"
self.pipeline.set_state(gst.STATE_PLAYING)
def OnStop(self, widget):
print "stop"
self.pipeline.set_state(gst.STATE_NULL)
def OnQuit(self, widget):
print "quitting"
gtk.main_quit()
start=Main()
gtk.main()*
Now I want to play a video in mpg. To do it, I would like to use the playbin
element but I don't arrive there.
Somebody knows how I could make that ?
Thanks,
Fab
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20080805/6a177d08/attachment.htm>
More information about the gstreamer-devel
mailing list