Fwd: [gst-devel] Getting started with gnonlin

Edward Hervey bilboed at gmail.com
Sat Jan 7 12:59:48 CET 2006


Forgot to CC the mailing list

---------- Forwarded message ----------
From: Edward Hervey <bilboed at gmail.com>
Date: Jan 7, 2006 7:54 PM
Subject: Re: [gst-devel] Getting started with gnonlin
To: Dominique Würtz <housirer at gmx.de>


Hi,

On 1/7/06, Dominique Würtz <housirer at gmx.de> wrote:
> Thanks a lot for clearing things up! With the modifications you
> mentioned my previous script works fine.
> Now I want to go one step further and play two audio snippets one after
> another. Here is the new code which unfortunately does not work again:
>
> import pygst
> pygst.require('0.10')
> import gst
> import gobject
>
> def _audiocomp_new_pad_cb(self, pad):
>         audiocomp.link(sink)
>
> sink = gst.element_factory_make("alsasink")
> audiocomp = gst.element_factory_make("gnlcomposition")
>
> source1 = gst.element_factory_make("gnlfilesource")
> source1.set_property("location", "foo.wav")
> source1.set_property("duration", 2 * gst.SECOND)
>
> source2 = gst.element_factory_make("gnlfilesource")
> source2.set_property("location", "bar.wav")
> source2.set_property("start", 2 * gst.SECOND)
> source2.set_property("duration", 2 * gst.SECOND)
>
> audiocomp.add(source1, source2)
> audiocomp.connect("pad-added", _audiocomp_new_pad_cb)
>
> pipeline = gst.Pipeline()
> pipeline.add(audiocomp, sink)
>
> pipeline.set_state(gst.STATE_PLAYING)
> gobject.MainLoop().run()
> pipeline.set_state(gst.STATE_NULL)
>
> In this case only source1 is played (for 2 seconds).
>

   I had a look, the handling of segment messages with format
different form GST_FORMAT_TIME was handled wrongly in gnlobject. I
commited the fixes to cvs. But there are still some issues regarding
not having enough data to properly decode the second segment (seeking
to 2s in the mp3 stream, whereas the previous chunk of mp3 starts
earlier), I'll still be looking into that.

> Another question is how gnonlin handles gaps. Since it's media type
> agnostic I assume it won't output silence automatically at times not
> covered by a source. Does a composition with gaps result in undefined
> behaviour? Do I need to add a silence source with low priority and
> "infinite" duration to fill the gaps?

  Let's take the example where you have your first source from 0s to
2s and your second from 5s to 10s. What will happen is that two
segments of 'data' will be outputted with the correct timestamps and
newsegment events. This is what really happens 'under the hood'.

  If you connect your composition to an audiosink, the sink will wait
for 3s after the first segment, before playing data from the second
segment.
  If you connect your composition to an encoder.... expect serious borkage :)

  The 'trick' for the second case, is to put a 'blanking' gnlsource
(audiotestsrc for audio or videotestsrc) with a priority (the actual
property value) set very high, so that the composition will play that
blanking source if there are gaps.
  In the previous version of gnonlin, you could set a source with a
priority of G_MAXINT and it would only be played during blanks. I will
add that feature again soon.

>
> Dominique

  Take care,

    Edward

>
> Edward Hervey wrote:
>
> >Hi,
> >
> >  Nice to see more people using gnonlin :)
> >
> >On 1/6/06, Dominique Würtz <housirer at gmx.de> wrote:
> >
> >
> >>I tried out the latest gnonlin (0.10.0.3) since I plan to use it for my
> >>project. I created a little Python script to to test its functionality.
> >>Unfortunately it wouldn't work. I think the pipeline gets stuck in the
> >>PREROLL state. The timeline source pad however is created.
> >>Here is the code:
> >>
> >>
> >
> >  I'll comment along the way:
> >
> >
> >
> >>import gst
> >>
> >>
> >
> > I suppose you only have gst-python >= 0.10 installed, otherwise you
> >should do the following before importing gst:
> >  import pygst
> >  pygst.require('0.10')
> >
> >
> >
> >>import gobject
> >>
> >>def _timeline_new_pad_cb(self, pad):
> >>        timeline.link(sink)
> >>
> >>sink = gst.element_factory_make("alsasink")
> >>timeline = gst.element_factory_make("gnltimeline")
> >>audiocomp = gst.element_factory_make("gnlcomposition")
> >>
> >>gnlsource = gst.element_factory_make("gnlfilesource")
> >>gnlsource.set_property("location", "foo.wav")
> >>gnlsource.set_property("media-start", 0L)
> >>gnlsource.set_property("media-duration", 100000L)
> >>
> >>
> >
> >  1000000 is one millisecond ! You'd be better off using the
> >gst.SECOND (or gst.MSECOND,...).
> >
> >
> >
> >>gnlsource.set_property("start", 0L)
> >>gnlsource.set_property("duration", 100000L)
> >>audiocomp.add(gnlsource)
> >>
> >>audiocomp.set_property("media-start", 0L)
> >>audiocomp.set_property("media-duration", 100000L)
> >>audiocomp.set_property("start", 0L)
> >>audiocomp.set_property("duration", 100000L)
> >>
> >>
> >
> >  For the time being, gnlcomposition have the (media)[start|duration]
> >automatically set to it's contents (in this case it will be set to the
> >duration of you gnlsource).
> >
> >
> >
> >>timeline.set_property("media-start", 0L)
> >>timeline.set_property("media-duration", 100000L)
> >>timeline.set_property("start", 0L)
> >>timeline.set_property("duration", 100000L)
> >>timeline.add(audiocomp)
> >>
> >>
> >
> >  I'm slapping myself really hard :( The gnltimeline and gnloperation
> >do nothing for the time being. In fact gnltimeline is going to go away
> >(with the gnlobject-0.10 way of working, you can just replace it with
> >a bin, if you really need that).
> >
> >
> >
> >>timeline.connect("pad-added", _timeline_new_pad_cb)
> >>
> >>pipeline = gst.Pipeline()
> >>pipeline.add(timeline, sink)
> >>
> >>
> >
> >  Because of the previous comment, replace all mention of gnltimeline
> >with your audiocomp.
> >
> >
> >
> >>pipeline.set_state(gst.STATE_PLAYING)
> >>gobject.MainLoop().run()
> >>pipeline.set_state(gst.STATE_NULL)
> >>
> >>Just a side note:
> >>
> >>This works: gst-launch filesrc location="foo.wav" ! decodebin ! alsasink
> >>While this won't: gst-launch gnlfilesrc location="foo.wav" ! decodebin !
> >>alsasink
> >>
> >>
> >
> >  The gnlfilesource contains decodebin within (it's it's purpose, just
> >give a location and (if needed) a caps). Also, the default values for
> >(media)[start|duration] are set to 0, so it will play for... 0
> >nanoseconds :)
> >
> >
> >
> >>Any ideas why the pipeline won't play?
> >>
> >>
> >>
> >
> >  Try following all the instructions given above. Although with latest
> >cvs, there seems to be an issue, where the fakesink contained in
> >decodebin doesn't get removed. I'm having a look at it now.
> >
> >  Edward
> >
> >
> >
> >>-------------------------------------------------------
> >>This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> >>for problems?  Stop!  Download the new AJAX search engine that makes
> >>searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> >>http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> >>_______________________________________________
> >>gstreamer-devel mailing list
> >>gstreamer-devel at lists.sourceforge.net
> >>https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >>
> >>
> >>
> >
> >
> >--
> >Edward Hervey
> >Junior developer / Fluendo S.L.
> >http://www.pitivi.org/
> >
> >
>
>


--
Edward Hervey
Junior developer / Fluendo S.L.
http://www.pitivi.org/


--
Edward Hervey
Junior developer / Fluendo S.L.
http://www.pitivi.org/


More information about the gstreamer-devel mailing list