[gst-devel] Problem using gnlcomposition
Hardeep Singh
hardy_hardeep at yahoo.co.in
Thu Mar 25 01:03:46 CET 2010
Hi
I am new to gstreamer development( and also Python!) and beginning to like it. I am trying to merge two video files using gnonlin components. The problem is a very common one, concatenating two video files together.
Gnlcomposition does that perfectly when test sources are used with gnlsource as data source for gnlcomposition. However if we use two file sources( either via gnlsource or gnlfilesource), the output video consists only of the second file. It looks like some problem with handling multiple file sources by gnlcomposition. I used the latest gnonlin libraries release this month. Is there a fix or work around for this? Or I am doing something wrong?
Here is the code for merging the files.
import sys
import pygst
import gst
import gobject
class Merger:
#Constructor
def __init__(self):
'''
Constructor
'''
self.mainloop = gobject.MainLoop()
self.player = gst.Pipeline("player")
self.conv = gst.element_factory_make ("ffmpegcolorspace","ffmpeg-colorspace")
mpeg4Encoder = gst.element_factory_make ("ffenc_mpeg4","encoder")
mpeg4Mux = gst.element_factory_make ("ffmux_mp4","muxer")
#imageSink = gst.element_factory_make ("xvimagesink","imageSink")
sink = gst.element_factory_make ("filesink","sink")
sink.set_property("location","/home/developer/merge.mp4")
comp = gst.element_factory_make("gnlcomposition", "mycomposition")
gnlfilesource1 = gst.element_factory_make("gnlfilesource", "video1")
gnlfilesource2 = gst.element_factory_make("gnlfilesource", "video2")
gnlfilesource1.set_property("location", sys.argv[1])
gnlfilesource1.set_property("start", 0 * gst.SECOND)
gnlfilesource1.set_property("duration", 6 * gst.SECOND)
gnlfilesource1.set_property("media-start", 0 * gst.SECOND)
gnlfilesource1.set_property("media-duration", 3 * gst.SECOND)
gnlfilesource1.set_property('caps', gst.caps_from_string('video/x-raw-yuv,width=190,height=240,framerate=30/1'))
gnlfilesource2.set_property("location", sys.argv[2])
gnlfilesource2.set_property("start", 3 * gst.SECOND)
gnlfilesource2.set_property("duration", 6 * gst.SECOND)
gnlfilesource2.set_property("media-start", 0 * gst.SECOND)
gnlfilesource2.set_property("media-duration", 3 * gst.SECOND)
gnlfilesource2.set_property('caps', gst.caps_from_string('video/x-raw-yuv,width=190,height=240,framerate=30/1'))
comp.add(gnlfilesource1,gnlfilesource2)
#put all elements in a bin
self.player.add(comp, self.conv, mpeg4Encoder, mpeg4Mux, sink)
gst.element_link_many(self.conv, mpeg4Encoder, mpeg4Mux, sink)
bus = self.player.get_bus()
bus.add_signal_watch ()
bus.connect("message",self.onMessage)
comp.connect("pad-added", self.onDynamicPad)
#functions
def run(self):
# Now set to playing and iterate.
print "Setting to Playing"
self.player.set_state(gst.STATE_PLAYING)
self.mainloop.run()
#clean up
print "Returned, stopping playback"
self.player.set_state (gst.STATE_NULL)
print "Deleting pipeline\n"
def onMessage(self,bus, message):
t = message.type
if t == gst.MESSAGE_EOS:
#print "Message EOS"
self.mainloop.quit()
elif t == gst.MESSAGE_ERROR:
err, debug = message.parse_error()
print "Error: %s" % err, debug
self.mainloop.quit()
def onDynamicPad(self,compbin,pad):
print "onDynamicPad called"
convSinkPad = self.conv.get_compatible_pad(pad, pad.get_caps())
pad.link(convSinkPad)
Thanks
The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
More information about the gstreamer-devel
mailing list