[gst-devel] Getting started with gnonlin
Dominique Würtz
housirer at gmx.de
Sat Jan 7 10:26:57 CET 2006
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).
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?
Dominique
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/
>
>
More information about the gstreamer-devel
mailing list