GnlOperation help

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

GnlOperation help

Mike MacHenry
Bellow I've pasted a python script which I expect to play a mp3 I have
for 100 seconds. I expect that it should play from 10 seconds in to
110 seconds. but it seems to be ignoring my media-start property. The
second issue is that the gnloperation seems to do nothing at all. I
want it to mute the stream from 1 second in for 20 seconds but the
audio just plays as normal. Anyone know what I'm doing wrong?

Thanks for the help,
-mike

import gobject
gobject.threads_init()
import pygst
pygst.require("0.10")
import gst

pipeline = gst.Pipeline()
gnlcomposition = gst.element_factory_make("gnlcomposition")
audioconvert = gst.element_factory_make("audioconvert")
alsasink = gst.element_factory_make("alsasink")

filesrc = gst.element_factory_make("gnlfilesource")
filesrc.set_property("location","/home/dskippy/17years.mp3")
filesrc.set_property("start", 0 * gst.SECOND)
filesrc.set_property("duration", 100 * gst.SECOND)
filesrc.set_property("media-start", 10 * gst.SECOND)
filesrc.set_property("media-duration", 100 * gst.SECOND)
filesrc.set_property("priority", 2)
gnlcomposition.add(filesrc)

op = gst.element_factory_make("gnloperation")
op.set_property("start", 1 * gst.SECOND)
op.set_property("duration", 20 * gst.SECOND)
op.set_property("priority", 1)
v = gst.element_factory_make("volume")
v.set_property("mute", True)
op.add(v)
gnlcomposition.add(op)

pipeline.add(gnlcomposition, audioconvert, alsasink)
gst.element_link_many(audioconvert, alsasink)
def OnPad (comp, pad):
        convpad = audioconvert.get_compatible_pad(pad, pad.get_caps())
        pad.link(convpad)
gnlcomposition.connect("pad-added", OnPad)

def get_message(src, message):
        print message
bus = pipeline.get_bus()
bus.add_signal_watch()
watch_id = bus.connect("message", get_message)

pipeline.set_state(gst.STATE_PLAYING)

gobject.MainLoop().run()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GnlOperation help

Edward Hervey
Administrator
Hi,

  What version of gstreamer/gst-plugins-base/gst-plugins-ugly/gnonlin do
you have ?

  Does it output any warnings while playing (GST_DEBUG=2 python
myscript.py) ?

     Edward

On Sat, 2008-02-09 at 18:29 -0500, Mike MacHenry wrote:

> Bellow I've pasted a python script which I expect to play a mp3 I have
> for 100 seconds. I expect that it should play from 10 seconds in to
> 110 seconds. but it seems to be ignoring my media-start property. The
> second issue is that the gnloperation seems to do nothing at all. I
> want it to mute the stream from 1 second in for 20 seconds but the
> audio just plays as normal. Anyone know what I'm doing wrong?
>
> Thanks for the help,
> -mike
>
> import gobject
> gobject.threads_init()
> import pygst
> pygst.require("0.10")
> import gst
>
> pipeline = gst.Pipeline()
> gnlcomposition = gst.element_factory_make("gnlcomposition")
> audioconvert = gst.element_factory_make("audioconvert")
> alsasink = gst.element_factory_make("alsasink")
>
> filesrc = gst.element_factory_make("gnlfilesource")
> filesrc.set_property("location","/home/dskippy/17years.mp3")
> filesrc.set_property("start", 0 * gst.SECOND)
> filesrc.set_property("duration", 100 * gst.SECOND)
> filesrc.set_property("media-start", 10 * gst.SECOND)
> filesrc.set_property("media-duration", 100 * gst.SECOND)
> filesrc.set_property("priority", 2)
> gnlcomposition.add(filesrc)
>
> op = gst.element_factory_make("gnloperation")
> op.set_property("start", 1 * gst.SECOND)
> op.set_property("duration", 20 * gst.SECOND)
> op.set_property("priority", 1)
> v = gst.element_factory_make("volume")
> v.set_property("mute", True)
> op.add(v)
> gnlcomposition.add(op)
>
> pipeline.add(gnlcomposition, audioconvert, alsasink)
> gst.element_link_many(audioconvert, alsasink)
> def OnPad (comp, pad):
>         convpad = audioconvert.get_compatible_pad(pad, pad.get_caps())
>         pad.link(convpad)
> gnlcomposition.connect("pad-added", OnPad)
>
> def get_message(src, message):
>         print message
> bus = pipeline.get_bus()
> bus.add_signal_watch()
> watch_id = bus.connect("message", get_message)
>
> pipeline.set_state(gst.STATE_PLAYING)
>
> gobject.MainLoop().run()
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GnlOperation help

Brandon Lewis-2
Edward Hervey wrote:

> Hi,
>
>   What version of gstreamer/gst-plugins-base/gst-plugins-ugly/gnonlin do
> you have ?
>
>   Does it output any warnings while playing (GST_DEBUG=2 python
> myscript.py) ?
>
>      Edward
>
> On Sat, 2008-02-09 at 18:29 -0500, Mike MacHenry wrote:
>> Bellow I've pasted a python script which I expect to play a mp3 I have
>> for 100 seconds. I expect that it should play from 10 seconds in to
>> 110 seconds. but it seems to be ignoring my media-start property. The
>> second issue is that the gnloperation seems to do nothing at all. I
>> want it to mute the stream from 1 second in for 20 seconds but the
>> audio just plays as normal. Anyone know what I'm doing wrong?
>>
>> Thanks for the help,
>> -mike
>>
>> import gobject
>> gobject.threads_init()
>> import pygst
>> pygst.require("0.10")
>> import gst
>>
>> pipeline = gst.Pipeline()
>> gnlcomposition = gst.element_factory_make("gnlcomposition")
>> audioconvert = gst.element_factory_make("audioconvert")
>> alsasink = gst.element_factory_make("alsasink")
>>
>> filesrc = gst.element_factory_make("gnlfilesource")
>> filesrc.set_property("location","/home/dskippy/17years.mp3")
>> filesrc.set_property("start", 0 * gst.SECOND)
>> filesrc.set_property("duration", 100 * gst.SECOND)
>> filesrc.set_property("media-start", 10 * gst.SECOND)
>> filesrc.set_property("media-duration", 100 * gst.SECOND)
>> filesrc.set_property("priority", 2)
>> gnlcomposition.add(filesrc)
>>
>> op = gst.element_factory_make("gnloperation")
>> op.set_property("start", 1 * gst.SECOND)
>> op.set_property("duration", 20 * gst.SECOND)
>> op.set_property("priority", 1)
>> v = gst.element_factory_make("volume")
>> v.set_property("mute", True)
>> op.add(v)
>> gnlcomposition.add(op)
>>
>> pipeline.add(gnlcomposition, audioconvert, alsasink)
>> gst.element_link_many(audioconvert, alsasink)
>> def OnPad (comp, pad):
>>         convpad = audioconvert.get_compatible_pad(pad, pad.get_caps())
>>         pad.link(convpad)
>> gnlcomposition.connect("pad-added", OnPad)
>>
>> def get_message(src, message):
>>         print message
>> bus = pipeline.get_bus()
>> bus.add_signal_watch()
>> watch_id = bus.connect("message", get_message)
>>
>> pipeline.set_state(gst.STATE_PLAYING)
>>
>> gobject.MainLoop().run()
>>

I ran a slightly modified version of his demo (uses sys.argv[1] instead
of hard-coded file path, and I disabled his message-handler callback).
Ran the program with the GST_DEBUG=2 on a .flac file, and this the
output that showed up.

$ GST_DEBUG=2 python test.py Music/Albums/flac/Beatles\ -\ Abbey\
Road/01\ -\ Come\ Together.flac
0:00:00.511432000  5637 0x81c9ed8 WARN        gnlcomposition
gnlcomposition.c:625:get_current_position:<gnlcomposition0> No current
stack, can't send query
0:00:00.584581000  5637 0x81c9ed8 WARN        gnlcomposition
gnlcomposition.c:625:get_current_position:<gnlcomposition0> No current
stack, can't send query
0:00:00.693505000  5637 0x81c9ed8 WARN             gnlsource
gnlsource.c:526:gnl_source_change_state:<gnlfilesource0> Couldn't find a
valid source pad
0:00:00.926743000  5637 0x835c118 ERROR       gnlcomposition
gnlcomposition.c:1391:no_more_pads_object_cb:<gnlcomposition0> Sending
seek event failed!
Traceback (most recent call last):
   File "test.py", line 45, in <module>
     gobject.MainLoop().run()

As mike said, he file does play normally, but the muting gnloperation
does nothing.

>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GnlOperation help

Brandon Lewis-2
In reply to this post by Edward Hervey
forgot to mention that i'm using the ubuntu feisty build of gstreamer,
0.10.14, gnonlin 0.10.9-1

--brandon


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GnlOperation help

Mike MacHenry
It turns out the failing to seek was my mp3. I tried with one that I
made with gstreamer itself and it work. It must be some odd caps
issue. I had a little more luck with the operation as well. I copied
some code right from the Instrument.py of Jokosher. This is what I'm
using now...

        def add_fade (self, start, duration, start_volume, end_volume):
                volumeFadeBin = gst.element_factory_make("bin")
                volumeFadeElement = gst.element_factory_make("volume")
                volumeFadeStartConvert =
gst.element_factory_make("audioconvert")
                volumeFadeEndConvert = gst.element_factory_make("audioconvert")
                volumeFadeOperation = gst.element_factory_make("gnloperation")
                volumeFadeController =
gst.Controller(volumeFadeElement, "volume")
                volumeFadeBin.add(volumeFadeElement)
                volumeFadeBin.add(volumeFadeStartConvert)
                volumeFadeBin.add(volumeFadeEndConvert)
                volumeFadeBinSink = gst.GhostPad("sink",
volumeFadeStartConvert.get_pad("sink"))
                volumeFadeBin.add_pad(volumeFadeBinSink)
                volumeFadeBinSrc = gst.GhostPad("src",
volumeFadeEndConvert.get_pad("src"))
                volumeFadeBin.add_pad(volumeFadeBinSrc)
                volumeFadeOperation.set_property("start", start * gst.SECOND)
                volumeFadeOperation.set_property("duration", duration
* gst.SECOND)
                volumeFadeOperation.set_property("priority", 1)
                volumeFadeController.set_interpolation_mode("volume",
gst.INTERPOLATE_LINEAR)
                volumeFadeOperation.add(volumeFadeBin)
                self.gnlcomposition.add(volumeFadeOperation)
                volumeFadeStartConvert.link(volumeFadeElement)
                volumeFadeElement.link(volumeFadeEndConvert)
                volumeFadeController.set("volume", start * gst.SECOND,
start_volume)
                volumeFadeController.set("volume", (start+duration) *
gst.SECOND, end_volume)
                return (volumeFadeController, volumeFadeOperation)

This worked in my simple test so I think this is correct. The one
problem I am having with this I'm going to have to debug and reduce a
little more before I come for help. I have an infinite gnlcomposition
that I keep adding to and tossing in these operations cause it errors
when they tried to get cleanup up. More on this later. thanks for the
help.

-mike

On Feb 11, 2008 1:56 PM, Brandon Lewis <[hidden email]> wrote:

> forgot to mention that i'm using the ubuntu feisty build of gstreamer,
> 0.10.14, gnonlin 0.10.9-1
>
> --brandon
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel