"decodebin ! encodebin" gives only video

Thiago Santos thiagoss at osg.samsung.com
Wed May 27 21:38:05 PDT 2015


On 04/28/2015 02:53 PM, Harry wrote:
> Testing the trivial :
>    gst_parse_launch ("filesrc name=src ! decodebin name=dec ! encodebin name=enc ! filesink name=sink", &error);
>
> I set the "location" property files for src & sink and I set "profile" for encodebin.
> The profile has valid video & audio caps for encoding.
> Result: The pipeline plays thru correctly, but the resulting file has only video, no audio.
>
> Thinking that the problem was unconnected pads, I added a "pad-added" signal-handler to decodebin like this:
>
> static void
> decodebin_pad_cb (GstElement * decodebin, GstPad * pad, GstElement * encodebin)
> {
>    GstPad        *sinkpad;
>    GstCaps       *caps;
>
>    sinkpad = gst_element_get_compatible_pad (encodebin, pad, NULL);
>
>    if (sinkpad == NULL) {                /* ask encodebin for a compatible pad */
>      caps = gst_pad_get_current_caps (pad);
>      if (caps) {
>        g_signal_emit_by_name (encodebin, "request-pad", caps, &sinkpad);
>        gst_caps_unref (caps);
>      }
>    }
>
>    if (sinkpad != NULL) {
>      if (!GST_PAD_IS_LINKED (sinkpad))    /* only link once */
>        gst_pad_link (pad, sinkpad);
>      gst_object_unref (sinkpad);
>    }
> }
>
> Result: The encoding process now continues for as long as I have patience to wait, never finishing.
>
> A hint for one of the problems might be that decodebin_pad_cb() is called 2 times and gst_pad_link() fails with error codes GST_PAD_LINK_WAS_LINKED and GST_PAD_LINK_NOFORMAT, probably first for video and then for audio (although the first error should really have been impossible with the GST_PAD_IS_LINKED() test).
Your gst-launch syntax has a '!' between decodebin and encodebin. This 
will make the gst_parse_launch lib set up a callback as well to link one 
of the pads. It is possible that you get the 'WAS_LINKED' error because 
the pad was already linked by the gstparse lib and then it goes into 
your callback. Removing the '!' between them should solve this issue.

I'd also recommend adding queues between decodebin and encodebin.
>
> Can someone explain the problem(s) ?
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


-- 
Thiago Sousa Santos
Senior Multimedia Engineer, Open Source Group
Samsung Research America - Silicon Valley



More information about the gstreamer-devel mailing list