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

☆樱花仙子☆ 提交于 2020-07-23 05:20:07

问题


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"


回答1:


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

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.



来源:https://stackoverflow.com/questions/54250779/gstreamer-how-to-link-decodebin-to-encodebin-error-failed-delayed-linking-so

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!