get_request_pad from encodebin return None

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

get_request_pad from encodebin return None

RiccardoCagnasso
Using python 3 / gi I'm trying to use encodebing get_request_pad('video_%u')
or get_request_pad('audio_%u') always returns None.

I tried also .emit('request-pad') with various Caps (like 'video/x-raw') to
the same result. Could this be a problem in configuring the profile? It
would be useful to find a up to date working example of encodebin in python



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
Not sure if this is related, but

118/385 gst-plugins-base / libs_pbutils         FAIL    20.94 s (exit status
1)



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

Thibault Saunier-4
In reply to this post by RiccardoCagnasso
Hello,


On Tue, Oct 9, 2018 at 8:18 AM RiccardoCagnasso <[hidden email]> wrote:
>
> Using python 3 / gi I'm trying to use encodebing get_request_pad('video_%u')
> or get_request_pad('audio_%u') always returns None.
>
> I tried also .emit('request-pad') with various Caps (like 'video/x-raw') to
> the same result. Could this be a problem in configuring the profile? It
> would be useful to find a up to date working example of encodebin in python

This all depends on the profile indeed, I do not think we have a
simple python example for that but you need to know that some the
format of a GstEncodingProfile has to match the caps for which you are
requesting a pad.

You could share your code sample so we can help you with that if you
can't get it working. Also a simple example would be very welcome ;)

Regards,

Thibault

> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
Yes, of course

import gi
from time import sleep
from threading import Event

gi.require_version('Gst', '1.0')

from gi.repository import Gst, GstPbutils  # noqa

Gst.init(None)

preset = None

encodebin = Gst.ElementFactory.make('encodebin')

ogg = Gst.Caps.from_string("application/ogg")
cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)

vorbis = Gst.Caps.from_string("audio/x-vorbis")
cprof.add_profile(GstPbutils.EncodingAudioProfile(vorbis, preset, vorbis,
0))

encodebin.set_property("profile", cprof)

encodebin.get_request_pad('video_%u') is None

https://pastebin.com/fCwNL258



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
The example is somewhat wrong because it sets up a audio encoder and then
request a video pad. Buy it yields the same result with

encodebin.get_request_pad('audio_%u') is None



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

Thibault Saunier-4
This is how it should look like:

```
import gi
from time import sleep
from threading import Event

gi.require_version('Gst', '1.0')

from gi.repository import Gst, GstPbutils  # noqa

Gst.init(None)

preset = None

encodebin = Gst.ElementFactory.make('encodebin')

ogg = Gst.Caps.from_string("application/ogg")
cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)

vorbis = Gst.Caps.from_string("audio/x-vorbis")
cprof.add_profile(GstPbutils.EncodingAudioProfile(vorbis, preset, vorbis, 0))

encodebin.set_property("profile", cprof)

print(encodebin.emit('request-pad', Gst.Caps('audio/x-vorbis')))
```

Thibault
On Tue, Oct 9, 2018 at 12:21 PM RiccardoCagnasso <[hidden email]> wrote:

>
> The example is somewhat wrong because it sets up a audio encoder and then
> request a video pad. Buy it yields the same result with
>
> encodebin.get_request_pad('audio_%u') is None
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
Ok, that works, thx.

But does it means that I've always to specify the Caps?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
In reply to this post by Thibault Saunier-4
Thibault Saunier-4 wrote

> This is how it should look like:
>
> ```
> import gi
> from time import sleep
> from threading import Event
>
> gi.require_version('Gst', '1.0')
>
> from gi.repository import Gst, GstPbutils  # noqa
>
> Gst.init(None)
>
> preset = None
>
> encodebin = Gst.ElementFactory.make('encodebin')
>
> ogg = Gst.Caps.from_string("application/ogg")
> cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)
>
> vorbis = Gst.Caps.from_string("audio/x-vorbis")
> cprof.add_profile(GstPbutils.EncodingAudioProfile(vorbis, preset, vorbis,
> 0))
>
> encodebin.set_property("profile", cprof)
>
> print(encodebin.emit('request-pad', Gst.Caps('audio/x-vorbis')))
> ```
>
> Thibault
> On Tue, Oct 9, 2018 at 12:21 PM RiccardoCagnasso &lt;

> riccardo@

> &gt; wrote:
>>
>> The example is somewhat wrong because it sets up a audio encoder and then
>> request a video pad. Buy it yields the same result with
>>
>> encodebin.get_request_pad('audio_%u') is None
>>
>>
>>
>> --
>> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
>> _______________________________________________
>> gstreamer-devel mailing list
>>

> gstreamer-devel@.freedesktop

>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list

> gstreamer-devel@.freedesktop

> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

I'm sorry, I can't wrap my head around your example. It seems to me that you
are requesting a sink to input audio/x-vorbis in an encodebin that should
encode audio/x-vorbis.

What I'm expect is to be ably to put audio/x-raw in it or eventually any
type of audio. something like this?


import gi
from time import sleep
from threading import Event

gi.require_version('Gst', '1.0')

from gi.repository import Gst, GstPbutils  # noqa

Gst.init(None)

encodebin = Gst.ElementFactory.make('encodebin')

ogg = Gst.Caps.from_string("video/x-matroska")
cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)

h264 = Gst.Caps.from_string("video/x-h264")
vaapih264enc = Gst.ElementFactory.make('vaapih264enc')
Gst.Preset.save_preset(vaapih264enc, 'vaapih264enc_preset')
video_profile = GstPbutils.EncodingVideoProfile(
    h264, 'vaapih264enc_preset', Gst.Caps.from_string('video/x-raw'), 0)
cprof.add_profile(video_profile)

encodebin.set_property("profile", cprof)

pad = encodebin.emit('request-pad', Gst.Caps('video/x-raw'))
print(pad)




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

Thibault Saunier-4
Re checked quickly and you first paste should almost work but, you are
using `GstPbutils.EncodingAudioProfile(vorbis, preset, vorbis, 0)`
instead of `GstPbutils.EncodingAudioProfile.new(vorbis, preset,
vorbis, 0)` which leads to the profile not being activated:

```
In [3]: vorbis = Gst.Caps.from_string("audio/x-vorbis")

In [4]: GstPbutils.EncodingAudioProfile(vorbis, None, vorbis, 0).is_enabled()
Out[4]: False

In [5]: GstPbutils.EncodingAudioProfile.new(vorbis, None, vorbis,
0).is_enabled()
0:00:18.999681729  5975 0x55db39f95930 ERROR                default
encoding-profile.c:1133:common_creation: Is enabled: 1
Out[5]: True
```

This is probably what you want (my previous paste is also correct but
depends on what you want):

```
import gi
from time import sleep
from threading import Event

gi.require_version('Gst', '1.0')

from gi.repository import Gst, GstPbutils  # noqa

Gst.init(None)

preset = None

encodebin = Gst.ElementFactory.make('encodebin')

ogg = Gst.Caps.from_string("application/ogg")
cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)

vorbis = Gst.Caps.from_string("audio/x-vorbis")
cprof.add_profile(GstPbutils.EncodingAudioProfile.new(vorbis, preset,
vorbis, 0))

encodebin.set_property("profile", cprof)

print(encodebin.get_request_pad('audio_%u'))
```
On Tue, Oct 9, 2018 at 2:45 PM RiccardoCagnasso <[hidden email]> wrote:

>
> Thibault Saunier-4 wrote
> > This is how it should look like:
> >
> > ```
> > import gi
> > from time import sleep
> > from threading import Event
> >
> > gi.require_version('Gst', '1.0')
> >
> > from gi.repository import Gst, GstPbutils  # noqa
> >
> > Gst.init(None)
> >
> > preset = None
> >
> > encodebin = Gst.ElementFactory.make('encodebin')
> >
> > ogg = Gst.Caps.from_string("application/ogg")
> > cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)
> >
> > vorbis = Gst.Caps.from_string("audio/x-vorbis")
> > cprof.add_profile(GstPbutils.EncodingAudioProfile(vorbis, preset, vorbis,
> > 0))
> >
> > encodebin.set_property("profile", cprof)
> >
> > print(encodebin.emit('request-pad', Gst.Caps('audio/x-vorbis')))
> > ```
> >
> > Thibault
> > On Tue, Oct 9, 2018 at 12:21 PM RiccardoCagnasso &lt;
>
> > riccardo@
>
> > &gt; wrote:
> >>
> >> The example is somewhat wrong because it sets up a audio encoder and then
> >> request a video pad. Buy it yields the same result with
> >>
> >> encodebin.get_request_pad('audio_%u') is None
> >>
> >>
> >>
> >> --
> >> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> >> _______________________________________________
> >> gstreamer-devel mailing list
> >>
>
> > gstreamer-devel@.freedesktop
>
> >> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > _______________________________________________
> > gstreamer-devel mailing list
>
> > gstreamer-devel@.freedesktop
>
> > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
> I'm sorry, I can't wrap my head around your example. It seems to me that you
> are requesting a sink to input audio/x-vorbis in an encodebin that should
> encode audio/x-vorbis.
>
> What I'm expect is to be ably to put audio/x-raw in it or eventually any
> type of audio. something like this?
>
>
> import gi
> from time import sleep
> from threading import Event
>
> gi.require_version('Gst', '1.0')
>
> from gi.repository import Gst, GstPbutils  # noqa
>
> Gst.init(None)
>
> encodebin = Gst.ElementFactory.make('encodebin')
>
> ogg = Gst.Caps.from_string("video/x-matroska")
> cprof = GstPbutils.EncodingContainerProfile("myprofile", None, ogg, None)
>
> h264 = Gst.Caps.from_string("video/x-h264")
> vaapih264enc = Gst.ElementFactory.make('vaapih264enc')
> Gst.Preset.save_preset(vaapih264enc, 'vaapih264enc_preset')
> video_profile = GstPbutils.EncodingVideoProfile(
>     h264, 'vaapih264enc_preset', Gst.Caps.from_string('video/x-raw'), 0)
> cprof.add_profile(video_profile)
>
> encodebin.set_property("profile", cprof)
>
> pad = encodebin.emit('request-pad', Gst.Caps('video/x-raw'))
> print(pad)
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
AH, yes! Now it works!



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: get_request_pad from encodebin return None

RiccardoCagnasso
This post was updated on .
Ok time to bother you guys with some more issues.

1) Even if I set "avoid-reencoding" to True, it seems to re-encode h264
strems in my tests, see this example

https://imgur.com/a/E4PYKd3

2) If i set an encoder preset like this

        vaapih264enc = Gst.ElementFactory.make('vaapih264enc')
        Gst.Preset.save_preset(vaapih264enc, 'vaapih264enc_preset')
        video_profile = GstPbutils.EncodingVideoProfile.new(
            h264, None, Gst.Caps.from_string("video/x-h264"), 0)

and then I try to add two video streams, it fails to deliver the second
video_pad with

(launchmodule.py:7846): GStreamer-WARNING **: 08:45:35.152:
gst_value_deserialize_g_value_array: unimplemented

(launchmodule.py:7846): GStreamer-WARNING **: 08:45:35.152: Name
'vaapiencodeh264-0' is not unique in bin 'encodebin0', not adding

(launchmodule.py:7846): GStreamer-CRITICAL **: 08:45:35.152:
gst_element_get_static_pad: assertion 'GST_IS_ELEMENT (element)' failed

(launchmodule.py:7846): GStreamer-CRITICAL **: 08:45:35.152:
gst_pad_link_full: assertion 'GST_IS_PAD (srcpad)' failed

(launchmodule.py:7846): GStreamer-CRITICAL **: 08:45:35.152:
gst_element_set_state: assertion 'GST_IS_ELEMENT (element)' failed

(launchmodule.py:7846): GStreamer-CRITICAL **: 08:45:35.153: gst_bin_remove:
assertion 'GST_IS_ELEMENT (element)' failed

wich kind of makes sense considering that the preset is an instance of an
encoder, but how can i work around this?

3) --- EDIT --- This was a problem in my software, nvm



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel