无法 boost::process 找到 gstreamer 插件
Cannot get boost::process to find gstreamer plugin
我正在尝试使用 boost::process 加载 gstreamer 插件来调用 gst-launch
。
当我通过命令行加载插件时,一切正常:
gst-launch-1.0 videotestsrc ! privacyprotector ! fakesink
如果我使用可执行文件的完整路径,它也能正常工作:
bp::child c("/opt/intel/openvino/data_processing/gstreamer/bin/gst-launch-1.0 videotestsrc ! privacyprotector ! fakesink", ec);
但是如果我尝试在路径中找到可执行文件并将参数作为单独的参数发送给 bp::child
,那么 gstreamer 无法找到插件:
bp::child c(bp::search_path("gst-launch-1.0"), bp::args("videotestsrc ! privacyprotector ! fakesink"), ec);
我是否遗漏了任何特定于参数处理的内容?
我认为参数需要是向量:
- https://www.boost.org/doc/libs/1_75_0/doc/html/boost_process/design.html#boost_process.design.arg_cmd_style
- https://www.boost.org/doc/libs/1_66_0/doc/html/boost/process/args.html
所以,试试
#include <boost/process.hpp>
#include <iostream>
namespace bp = boost::process;
int main() {
std::error_code ec;
bp::child c(
bp::search_path("gst-launch-1.0"),
bp::args = {"videotestsrc", "!", "privacyprotector", "!", "fakesink"},
ec);
c.wait();
std::cout << ec.message() << ": " << c.exit_code();
}
其中,在我的系统上打印:
WARNING: erroneous pipeline: no element "privacyprotector"
Success: 1
我正在尝试使用 boost::process 加载 gstreamer 插件来调用 gst-launch
。
当我通过命令行加载插件时,一切正常:
gst-launch-1.0 videotestsrc ! privacyprotector ! fakesink
如果我使用可执行文件的完整路径,它也能正常工作:
bp::child c("/opt/intel/openvino/data_processing/gstreamer/bin/gst-launch-1.0 videotestsrc ! privacyprotector ! fakesink", ec);
但是如果我尝试在路径中找到可执行文件并将参数作为单独的参数发送给 bp::child
,那么 gstreamer 无法找到插件:
bp::child c(bp::search_path("gst-launch-1.0"), bp::args("videotestsrc ! privacyprotector ! fakesink"), ec);
我是否遗漏了任何特定于参数处理的内容?
我认为参数需要是向量:
- https://www.boost.org/doc/libs/1_75_0/doc/html/boost_process/design.html#boost_process.design.arg_cmd_style
- https://www.boost.org/doc/libs/1_66_0/doc/html/boost/process/args.html
所以,试试
#include <boost/process.hpp>
#include <iostream>
namespace bp = boost::process;
int main() {
std::error_code ec;
bp::child c(
bp::search_path("gst-launch-1.0"),
bp::args = {"videotestsrc", "!", "privacyprotector", "!", "fakesink"},
ec);
c.wait();
std::cout << ec.message() << ": " << c.exit_code();
}
其中,在我的系统上打印:
WARNING: erroneous pipeline: no element "privacyprotector"
Success: 1