I have been looking for the method to use avidemux, pipelines and python to display the video and audio from a single avi video file. I can do it using gst-launch but i wanted to implement it in code. Right now it sais that all the elements are created but it doens't access any of the dynamic alloction of pads from the avidemux or the decoder.
The entire code for python is below.
Thanks,
#!/usr/bin/env python import gobject, pygst pygst.require("0.10") import gst def allocate_muxer_pad(dbin, pad, islast): print "allocate prog entered" if pad.get_caps()[0].to_string().startswith("a"): pad.link(audioqueue.get_pad("sink")) print 'audio Mux connected' elif pad.get_caps()[0].to_string().startswith("v"): pad.link(videoqueue.get_pad("sink")) print 'Video Mux connected' def new_Adecode_pad(dbin, pad, islast): pad.link(audioconvert.get_pad("sink")) print 'audio decode connected' def new_Vdecode_pad(dbin, pad, islast): pad.link(videoconvert.get_pad("sink")) print 'video decode connected' pipeline = gst.Pipeline("PIPELINE") Bin = gst.Bin("pipeline") src = gst.element_factory_make("filesrc", "source") src.set_property("location", "testav.avi") demux = gst.element_factory_make("avidemux","avi-demuxer") audioqueue = gst.element_factory_make('queue', 'Audioqueue') videoqueue = gst.element_factory_make('queue','videoqueue') audiodecoder = gst.element_factory_make("decodebin2","Adecoder") videodecoder = gst.element_factory_make("decodebin2","Vdecoder") audioconverter = gst.element_factory_make("audioconvert","Audio_Converter") videoconverter = gst.element_factory_make("ffmpegcolorspace","Video_Converter") audioSink = gst.element_factory_make("autoaudiosink","Sink_Audio") videoSink = gst.element_factory_make("ximagesink","Sink_Video") Bin.add(src) Bin.add_many(demux,audioqueue,videoqueue,audiodecoder,audioconverter,videodecoder,videoconverter,audioSink,videoSink) src.link(demux) gst.element_link_many(audioqueue,audiodecoder) gst.element_link_many(audioconverter,audioSink) gst.element_link_many(videoqueue,videodecoder) gst.element_link_many(videoconverter,videoSink) if (not(src) or not(demux) or not(audioqueue) or not(videoqueue) or not(videodecoder) or not(audiodecoder) or not(audioconverter) or not(videoconverter) or not(audioSink) or not(videoSink) ): print "Elements not Created" else: print "Elements Created" demux.connect("pad-added", allocate_muxer_pad) demux.connect("pad-added", allocate_muxer_pad) audiodecoder.connect("new-decoded-pad", new_Adecode_pad) videodecoder.connect("new-decoded-pad", new_Vdecode_pad) pipeline.set_state(gst.STATE_PLAYING) print "Pipeline Playing" # enter into a mainloop loop = gobject.MainLoop() loop.run()
the cell dickclark gavin degraw gavin degraw alec time 100 bob beckel
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.