[gst-devel] Problem using gnlcomposition

Edward Hervey bilboed at gmail.com
Thu Mar 25 08:31:53 CET 2010


Hi,

On Thu, 2010-03-25 at 05:33 +0530, Hardeep Singh wrote:
> 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)

 You've set a media-duration which is different from the duration.
You're attempting to playback 3seconds of media from your file in 6
seconds (If you connect a video sink to the output of the composition
you will see it playing back slower).

 Unless you *want* that behaviour, you should set duration and
media-duration to the same values.


>         gnlfilesource1.set_property('caps', gst.caps_from_string('video/x-raw-yuv,width=190,height=240,framerate=30/1'))

 Unless your file contains multiple video streams, you don't need to be
that specific about the stream. You can just use 'video/x-raw-yuv'. 

>             
>         gnlfilesource2.set_property("location", sys.argv[2])
>         gnlfilesource2.set_property("start", 3 * gst.SECOND)

 And here is your problem :)

 You asked the first clip to be positioned from 0 (start) to 6s (start
+duration) ... but then you put the second clip to be played from 3s
(start) to 9s (start+duration).

 Since the clips are overlapping and have the same priority, this is
causing total havoc.

>         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)

  The rest of your code seems correct.

  So to sum up:

  * Make sure you set duration and media-duration to the same values,
unless you want to change the playback rate.

  * Make sure clips with the same priority don't overlap in time.


  Tell us if that fixes your issues,

    Edward

> 
> 
> 
> Thanks
> 
> 
>       The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel






More information about the gstreamer-devel mailing list