简体   繁体   中英

Gstreamer: how to link decodebin to encodebin? (error: failed delayed linking some pad of …)

Naively, I am trying to link decodebin to encodebin:

$ gst-launch-1.0 filesrc location="/tmp/sound.wav" ! decodebin ! encodebin profile="application/ogg:video/x-theora:audio/x-vorbis" ! filesink location="/tmp/sound.ogg"
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:
failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstEncodeBin named encodebin0
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstWavParse:wavparse0: Internal data stream error.
Additional debug info:
gstwavparse.c(2293): gst_wavparse_loop (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstWavParse:wavparse0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

Surely, there is something missing. What is it?

Note, this works: gst-launch-1.0 filesrc location="/tmp/sound.wav" ! decodebin ! audioconvert ! vorbisenc ! oggmux ! filesink location="/tmp/sound.ogg" gst-launch-1.0 filesrc location="/tmp/sound.wav" ! decodebin ! audioconvert ! vorbisenc ! oggmux ! filesink location="/tmp/sound.ogg"

gst-launch-1.0 filesrc location="/tmp/sound.wav" ! decodebin ! encodebin profile="application/ogg:video/x-theora:audio/x-vorbis" ! filesink location="/tmp/sound.ogg"

encodebin doesn't have templates in their pads so gst-launch doesn't know which pad to request (video or audio). You can explicitly ask for one of them using:

gst-launch-1.0 filesrc location="/tmp/sound.wav" ! decodebin ! enc.audio_%u encodebin name=enc profile="application/ogg:video/x-theora:audio/x-vorbis" ! filesink location="/tmp/sound.ogg"

Notice how we give encodebin a name "enc" and then we link decodebin to the audio pad as we know that this is an audio-only file.

If we had both video and audio you'd need to link explicitly the video pad from decodebin to the video pad of encodebin and so forth. You would give a name to decodebin as well and link them. Something like: decodebin name=dec dec.audio_%u ! queue ! enc.audio_%u dec.video_%u ! queue ! enc.video_%u decodebin name=dec dec.audio_%u ! queue ! enc.audio_%u dec.video_%u ! queue ! enc.video_%u

As a final suggestion, it is recommended to have a queue after every element that can branch of into multiple paths, like decodebin. It is mandatory when you have more than one output from it, but doesn't hurt to have it even if you only have one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM