Gstreamer: how to link decodebin to encodebin? (error: failed delayed linking some pad of ...)
Gstreamer: how to link decodebin to encodebin? (error: failed delayed linking some pad of ...)
天真地,我正在尝试 link decodebin 到 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 ...
果然,少了点什么。这是什么?
请注意,这有效:
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 的 pad 中没有模板,因此 gst-launch 不知道要请求哪个 pad(视频或音频)。您可以使用以下方式明确要求其中之一:
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"
注意我们如何给 encodebin 命名 "enc" 然后我们 link decodebin 到音频板,因为我们知道这是一个纯音频文件。
如果我们同时拥有视频和音频,您需要 link 明确地将视频板从 decodebin 转移到 encodebin 的视频板等等。您也可以为 decodebin 命名,并 link 它们。类似于:decodebin name=dec dec.audio_%u ! queue ! enc.audio_%u dec.video_%u ! queue ! enc.video_%u
作为最后的建议,建议在每个可以分支到多个路径的元素之后有一个队列,例如 decodebin。当你有多个输出时它是强制性的,但即使你只有一个也没有坏处。
天真地,我正在尝试 link decodebin 到 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 ...
果然,少了点什么。这是什么?
请注意,这有效:
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 的 pad 中没有模板,因此 gst-launch 不知道要请求哪个 pad(视频或音频)。您可以使用以下方式明确要求其中之一:
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"
注意我们如何给 encodebin 命名 "enc" 然后我们 link decodebin 到音频板,因为我们知道这是一个纯音频文件。
如果我们同时拥有视频和音频,您需要 link 明确地将视频板从 decodebin 转移到 encodebin 的视频板等等。您也可以为 decodebin 命名,并 link 它们。类似于:decodebin name=dec dec.audio_%u ! queue ! enc.audio_%u dec.video_%u ! queue ! enc.video_%u
作为最后的建议,建议在每个可以分支到多个路径的元素之后有一个队列,例如 decodebin。当你有多个输出时它是强制性的,但即使你只有一个也没有坏处。