GNOME Bugzilla – Bug 689845
Encodebin API to handle multiple streams lacking
Last modified: 2013-03-31 10:37:22 UTC
Been looking at the API docs and I can not figure out how to do this. So I have an encodebin where I created to audio profiles, lets say one for vorbis and one for mp3. So I have a file decoded by uridecodebin which has two audio streams and I want to use the vorbis stream with one and the mp3 stream for the other. I can not figure out how to ask encodebin to give me a pad connected to a specific profile. The 'request-pad' signal only offers to give you a pad which can handle your incoming caps, but that would be raw audio data for both feeds.
Suggested "workaround" code from Alessandro. I will try to test this as soon as possible. def find_encodebin_pads(self, pad, pad_type): for sink_pad in self.encodebin.sinkpads: if pad.can_link(sink_pad): yield sink_pad template = Gst.PadTemplate.new(pad_type + '_%d', Gst.PadDirection.SINK, Gst.PadPresence.REQUEST, pad.query_caps()) sink_pad = self.encodebin.request_pad(template, pad_type + '_%d', pad.query_caps()) if sink_pad is not None: yield sink_pad
Realized upon trying this code that it doesn't help with this bug at all :) The challenge in this bug is having 2 audio streams and being able to choose what format to encode them into, the 'workaround' code above actually just does what the existing 'request-pad' signal already does which is provide a pad compatible with your incoming pad.
Been thinking about this bug over the holidays, I think the simplest API I can think of for this is that when you create the profile you can also give it a name, and then you should be able to use that name with the request-pad signal to request your specific profile.
One way to circumvent that limitation it to specify the encoded caps when requesting a pad. Encodebin will search for a profile that can accept those encoded caps ... even if you'll be sending it raw audio/video later on. gst_element_request_pad(encodebin, <a template>, "audio_1", gst_caps_new_simple("audio/x-vorbis"); or using the "request-pad" action signal Note that this will only work if your various profiles use different caps. If you have several profiles with *exactly* the same caps ... you can't make the difference. Trying to figure out a way to specify a profile another way.
Created attachment 240060 [details] [review] encodebin: Add action signal to get pad for a given profile This allows getting a pad for a specific encoding profile, which can be useful when there are several stream profiles of the same type. Also update the encodebin unit tests so that we check that the returned pad has the right caps.
commit b3d94bd0e4ce735c3529a20068689a1113a85639 Author: Edward Hervey <edward@collabora.com> Date: Thu Mar 28 15:20:19 2013 +0100 encodebin: Add action signal to get pad for a given profile This allows getting a pad for a specific encoding profile, which can be useful when there are several stream profiles of the same type. Also update the encodebin unit tests so that we check that the returned pad has the right caps. https://bugzilla.gnome.org/show_bug.cgi?id=689845