[英]Gstreamer Elements not linking
I am new to Gstreamer and I have a question about why my elements will not link together. 我是Gstreamer的新手,我有一个问题,为什么我的元素无法链接在一起。 Here is my code:
这是我的代码:
CustomData data;
data.videosource = gst_element_factory_make("uridecodebin", "source");
cout << "Created source element " << data.videosource << endl;
data.demuxer = gst_element_factory_make("qtdemux", "demuxer");
cout << "Created demux element " << data.demuxer << endl;
data.decoder = gst_element_factory_make("ffdec_h264", "video-decoder");
cout << "Went to the video path " << data.decoder << endl;
data.videoconvert = gst_element_factory_make("ffmpegcolorspace", "convert");
cout << "Created convert element " << data.videoconvert << endl;
data.videosink = gst_element_factory_make("autovideosink", "sink");
cout << "Created sink element " << data.videosink << endl;
if (!data.videosource ||!data.demuxer || !data.decoder || !data.videoconvert || !data.videosink)
{
g_printerr ("Not all elements could be created.\n");
system("PAUSE");
return;
}
//Creating the pipeline
data.pipeline = gst_pipeline_new("video-pipeline");
if (!data.pipeline)
{
g_printerr ("Pipeline could not be created.");
}
//Setting up the object
g_object_set(data.videosource, "uri", videoFileName[camID] , NULL);
//videoFileName[camID] is a char** with the content uri=file:///C://videofiles/...mp4
//Adding elements to the pipeline
gst_bin_add_many(GST_BIN (data.pipeline), data.videosource, data.demuxer, data.decoder, data.videoconvert, data.videosink, NULL);
//This is where the issue occurs
if(!gst_element_link(data.videosource, data.demuxer)){
g_printerr("Elements could not be linked. \n");
system("PAUSE");
return;
}
What I am trying to do is to break down a mp4 file and display only the video content but for some reason when I try to link source and demuxer, it comes out as false. 我想做的是分解mp4文件并仅显示视频内容,但是由于某些原因,当我尝试链接源和多路分配器时,它显示为false。
Thank you guys so much! 非常感谢你们!
Let's have a look at the pipeline you're using (I'll use gst-launch
here for its brevity, but the same goes for any GStreamer pipelines): 让我们看一下您正在使用的管道(为简洁起见,我将在这里使用
gst-launch
,但对于任何GStreamer管道也是如此):
gst-launch uridecodebin uri=file:///path/to/movie.avi \
! qtdemux ! ffdec_h264 ! ffmpegcolorspace \
! autovideosink
gst-inspect uridecodebin
states: gst-inspect uridecodebin
状态:
Autoplug and decode an URI to raw media 自动插入URI并将其解码到原始媒体
So uridecodebin
takes any audio/video source and decodes it by internally using some of GStreamer's other elements. 因此,
uridecodebin
可以获取任何音频/视频源,并通过内部使用GStreamer的其他一些元素对其进行解码。
Its output is something like video/x-raw-rgb
or audio/x-raw-int
(raw audio/video) 其输出类似于
video/x-raw-rgb
或audio/x-raw-int
(原始音频/视频)
qtdemux
on the other hand takes a QuickTime stream (still encoded) and demuxes it. 另一方面,
qtdemux
接收QuickTime流(仍进行编码)并将其解复用。
But what it gets in your example is the already decoded raw video (which is why it won't link). 但是在您的示例中得到的是已经解码的原始视频(这就是为什么它不会链接)的原因。
So, you've basically got two options: 因此,您基本上有两个选择:
just use uridecodebin
只需使用
uridecodebin
gst-launch uridecodebin uri=file:///path/to/movie.avi \\ ! autovideosink
which will allow your pipeline to decode pretty much any video file 这将使您的管道几乎可以解码任何视频文件
just use the qtdemux ! ffdec_h264 ! ffmpegcolorspace
只需使用
qtdemux ! ffdec_h264 ! ffmpegcolorspace
qtdemux ! ffdec_h264 ! ffmpegcolorspace
qtdemux ! ffdec_h264 ! ffmpegcolorspace
elements: qtdemux ! ffdec_h264 ! ffmpegcolorspace
元素:
gst-launch filesrc=/path/to/movie.avi \\ ! qtdemux ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
Keep in mind however that your pipeline doesn't play audio. 但是请记住,您的管道无法播放音频。
To get that as well do one of the following: 要获得此效果,请执行以下任一操作:
Simply use playbin2
只需使用
playbin2
gst-launch playbin2 uri=file:///path/to/movie.avi
decodebin
to an audio sink as well gst-launch uridecodebin name=d uri=... ! decodebin
到音频接收器以及GST推出uridecodebin名= d URI = ...! autovideosink d.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.