Reusing a pipeline

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

Reusing a pipeline

Jeffrey Barish
I created a class for ripping to a file.  It works fine once, but if I try
to use the same instance a second time, query_position or query_duration
returns a bogus value (I compute a ratio, so I'm not sure which is wrong).
I presume that something needs to be reinitialized before I use the
instance again, but I don't see my mistake.  Clues?  It works to create a
new instance each time.  Is it good GStreamer practice to re-create the
pipeline each time despite the inefficiency?

class Ripper(gst.Pipeline):
    def __init__(self):
        gst.Pipeline.__init__(self, 'ripper_pipeline')
        self.prop_dict = {}

        cd_src = gst.element_factory_make('cdparanoiasrc', 'cd_src')
        self.add(cd_src)
        self._register_property(cd_src, 'track')

        converter = gst.element_factory_make('audioconvert', 'converter')
        self.add(converter)

        encoder = gst.element_factory_make('vorbisenc', 'encoder')
        self.add(encoder)

        oggmux = gst.element_factory_make('oggmux', 'oggmux')
        self.add(oggmux)

        file_sink = gst.element_factory_make('filesink', 'file_sink')
        self.add(file_sink)
        self._register_property(file_sink, 'location')

        gst.element_link_many(cd_src, converter, encoder, oggmux, file_sink)

    def _register_property(self, element, prop):
        # Direct set_property calls to the right element.
        self.prop_dict[prop] = element

    def set_property(self, prop, val):
        element = self.prop_dict[prop]
        element.set_property(prop, val)
--
Jeffrey Barish


-------------------------------------------------------------------------
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: Reusing a pipeline

Tim-Philipp Müller-2
On Mon, 2008-02-04 at 19:38 -0700, Jeffrey Barish wrote:

> I created a class for ripping to a file.  It works fine once, but if I try
> to use the same instance a second time, query_position or query_duration
> returns a bogus value (I compute a ratio, so I'm not sure which is wrong).
> I presume that something needs to be reinitialized before I use the
> instance again, but I don't see my mistake.  Clues?

Do you set the pipeline state back to NULL when you're done and before
re-using it and setting state back to PLAYING?

If yes, maybe you could whip up a small self-contained program that
shows the problem and that people can run?


> It works to create a new instance each time. Is it good GStreamer
> practice to re-create the pipeline each time despite the inefficiency?

It is a prudent thing to do, at least for more complex pipelines. It
shouldn't be necessary, but unless someone actually goes to write tests
to make sure that all components are re-usable, chances are they may not
be. Also, it makes debugging a tad easier if you know you start from a
guaranteed sane zero state for each track. I very much doubt the
overhead of constructing your pipeline matters.

 Cheers
  -Tim



-------------------------------------------------------------------------
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: Reusing a pipeline

Stefan Sauer
hi,

Quoting Tim Müller <[hidden email]>:

> On Mon, 2008-02-04 at 19:38 -0700, Jeffrey Barish wrote:
>
>> I created a class for ripping to a file.  It works fine once, but if I try
>> to use the same instance a second time, query_position or query_duration
>> returns a bogus value (I compute a ratio, so I'm not sure which is wrong).
>> I presume that something needs to be reinitialized before I use the
>> instance again, but I don't see my mistake.  Clues?
>
> Do you set the pipeline state back to NULL when you're done and before
> re-using it and setting state back to PLAYING?
>
Set the pipeline to READY after using and then PLAYING again. NULL  
would render it useless.

Stefan

>
> If yes, maybe you could whip up a small self-contained program that
> shows the problem and that people can run?
>
>
>> It works to create a new instance each time. Is it good GStreamer
>> practice to re-create the pipeline each time despite the inefficiency?
>
> It is a prudent thing to do, at least for more complex pipelines. It
> shouldn't be necessary, but unless someone actually goes to write tests
> to make sure that all components are re-usable, chances are they may not
> be. Also, it makes debugging a tad easier if you know you start from a
> guaranteed sane zero state for each track. I very much doubt the
> overhead of constructing your pipeline matters.
>
>  Cheers
>   -Tim
>
>
>
> -------------------------------------------------------------------------
> 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: Reusing a pipeline

Tim-Philipp Müller-2
On Tue, 2008-02-05 at 14:36 +0100, Stefan Kost wrote:

> Set the pipeline to READY after using and then PLAYING again. NULL  
> would render it useless.

Oh really? Care to elaborate?

Cheers
 -Tim



-------------------------------------------------------------------------
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: Reusing a pipeline

Stefan Sauer
Hi,

I looked at the code up and down. It looks like going to NULL is not  
destroying anything that cannot be rebuild when leaving NULL. One myth  
less. Good.

So ready would be sufficient (and maybe more efficient) for most use  
cases still, but NULL should definitely work too (at least we hve  
tests for it: gstreamer/tests/check/generic/states.c)

Sorry for misinfo.

Stefan


Quoting Tim Müller <[hidden email]>:

> On Tue, 2008-02-05 at 14:36 +0100, Stefan Kost wrote:
>
>> Set the pipeline to READY after using and then PLAYING again. NULL
>> would render it useless.
>
> Oh really? Care to elaborate?
>
> Cheers
>  -Tim
>
>
>
> -------------------------------------------------------------------------
> 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: Reusing a pipeline

Jeffrey Barish
In reply to this post by Stefan Sauer
Stefan Kost wrote:

> Set the pipeline to READY after using and then PLAYING again. NULL
> would render it useless.

I did set the pipeline to NULL.  When I set the pipeline instead to READY, I
get the message:

WARNING **: Changing the `location' property on filesink when a file is open
not supported.

I suppose that I have to close the file, but I don't see a way to do that.

In the meantime, I am reassured by Tim's advice that reconstructing the
pipeline for every track is reasonable.
--
Jeffrey Barish


-------------------------------------------------------------------------
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: Reusing a pipeline

Florent THIERY-2
> I did set the pipeline to NULL.  When I set the pipeline instead to READY, I
> get the message:
>
> WARNING **: Changing the `location' property on filesink when a file is open
> not supported.

I get the same issue too with a pipeline; tried a lot of different
approaches for achieving the following: a video pipeline that gets
both rendered on the screen and ocasionally backuped. What happens at
best is that when you start backup, stop backup (1st file), restart
backup (2nd backup file), the 2nd file stays empty. In other cases, i
get the very same warning as you do.

The current solution is stopping the pipeline, and restart another
(quite horrible).

> I suppose that I have to close the file, but I don't see a way to do that.

I second this, what's the proper way to do this ? Is some "flushing" required ?

> In the meantime, I am reassured by Tim's advice that reconstructing the
> pipeline for every track is reasonable.

It is, yet you do notice a glitch/interruption. For live video it can
be an issue.

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