简体   繁体   中英

Gstreamer - using a variable for video path

I have a question concerning Gstreamer and the path for the video (uri). Indeed, in order to try my code, I used to set the path to my video directly in the C++ source code, that way :

data.pipeline = gst_parse_launch ("playbin2 uri=file:///D:/video", NULL);

But now, I am using a user interface (wxWidgets) in order to get the path to the video that the user wants to play. The path is now in a variable, m_txtVideoPath. And I don't know how I can launch the video using this variable, instead of D:/video.

Thanks in advance for your answer !

you have to construct the pipeline with the user-defined filename, rather than hardcode everything.

this is very basic string handling, you might want to consult a beginner's tutorial for your programming language of choice.

eg

 std::string pipeline = "playbin2";
 pipeline+=" uri=file://"+m_txtVideoPath;
 std::cout << "PIPELINE: " << pipeline << std::endl; // for debugging
 data.pipeline = gst_parse_launch (pipeline.c_str(), NULL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM