gstreamer - Gstreamer:如何将 decodebin 链接到 encodebin?(错误:未能延迟链接某些垫......)
问题描述
天真地,我试图将 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”,然后我们将 decodebin 链接到音频垫,因为我们知道这是一个纯音频文件。
如果我们同时拥有视频和音频,您需要将视频板从 decodebin 显式链接到 encodebin 的视频板,依此类推。您也可以为 decodebin 命名并链接它们。就像是:decodebin name=dec dec.audio_%u ! queue ! enc.audio_%u dec.video_%u ! queue ! enc.video_%u
作为最后的建议,建议在每个可以分支到多个路径的元素之后都有一个队列,例如 decodebin。当你有多个输出时,它是强制性的,但即使你只有一个,拥有它也没有什么坏处。
推荐阅读
- android - 我正在从 Firebase 实时数据库中获取数据,但我得到空对象
- android - 亚行无法打开列出并允许添加账户的账户设置
- linux - Sed 删除文件夹内文件文本中的最后 4 个字符
- python - 无法从 node.js spawn 存储或发送 json 输出
- r - 有没有办法通过 R 中每行的存在来计算值?
- nodemailer - 使用 nodemailer 发送电子邮件时,Gmail 不尊重电子邮件别名
- javascript - REPL 中 NodeJs 预加载选项 (-r) 和显式要求之间的区别
- reactjs - 错误:无法解析模块 ./Easing from node_modules\react-native-reanimated\src\Animated.js
- javascript - 需要并排显示页眉和图像
- angular - 将 mt HTTP 转换为 Observable 时出现多个错误