我有一个简单的代码与c++使用gstreamer读取rtsp视频。我是gstreamer的新手,我无法将gst_parse_launch()与rtsp链接的URL_RTSP变量连接起来。
这里没有变量URL_RTSP,它可以工作:
/* Build the pipeline */
pipeline = gst_parse_launch("rtspsrc protocols=tcp location=rtsp://user:pass@protocol:port/cam/realmonitor?channel=1&subtype=0 latency=300 ! decodebin3 ! autovideosink", NULL);
/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);对于变量URL_RTSP,不起作用:
/*Url Cams*/
std::string URL_RTSP = "rtsp://user:pass@protocol:port/cam/realmonitor?channel=1&subtype=0";
/* Build the pipeline */
pipeline =
gst_parse_launch("rtspsrc protocols=tcp location="+ URL_RTSP + " latency=300 ! decodebin3 ! autovideosink", NULL);
/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);当我尝试使用with变量时,gst_parse_launch()获得错误:
there is no proper conversion function from "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>" to "const gchar *"发布于 2022-09-13 19:35:58
gst_parse_launch将const gchar*作为第一个参数:
GstElement* gst_parse_launch (const gchar* pipeline_description, GError** error)但是,你提供的,
"rtspsrc protocols=tcp location="+ URL_RTSP +
" latency=300 ! decodebin3 ! autovideosink"结果为std::string。我建议先创建std::string,然后使用c_str()成员函数传递const char*。
std::string tmp =
"rtspsrc protocols=tcp location=" + URL_RTSP +
" latency=300 ! decodebin3 ! autovideosink";
pipeline = gst_parse_launch(tmp.c_str(), nullptr);https://stackoverflow.com/questions/73708226
复制相似问题