Gstreamer1.0:链接去codeBIN到videoconvert [英] Gstreamer1.0 : link a decodebin to videoconvert
问题描述
我有以下的管道的正常工作:
I have the following pipeline which works fine:
GST-推出-1.0 -v filesrc位置= /家庭/视频/ sample_h264.mov!德codeBIN! videoconvert! autovideosink
gst-launch-1.0 -v filesrc location=/home/Videos/sample_h264.mov ! decodebin ! videoconvert ! autovideosink
我想写一个C程序做同样的事情。所以我翻译的previous管道下面code:
I want to write a C program to do the same thing. So I translated the previous pipeline to the following code:
pipeline = gst_pipeline_new ("video_pipeline");
if (!pipeline) {
g_print("Failed to create the pipeline\n");
return -1;
}
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
source = gst_element_factory_make ("filesrc", "file-source");
decoder = gst_element_factory_make ("decodebin", "standard-decoder");
converter = gst_element_factory_make ("videoconvert", "converter");
sink = gst_element_factory_make ("autovideosink", "video-sink");
if (!source || !decoder || !converter || !sink) {
g_print("Failed to create one or more pipeline elements\n");
return -1;
}
g_object_set(G_OBJECT(source), "location", file_name, NULL);
gst_bin_add_many (GST_BIN (pipeline), source, decoder, converter, sink, NULL);
if (!gst_element_link_many (source, decoder, converter, sink, NULL)) {
g_print ("Failed to link some elements!\n");
return -1;
}
/* run */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
GstMessage *msg;
g_print ("Failed to start up pipeline!\n");
/* check if there is an error message with details on the bus */
msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
if (msg) {
GError *err = NULL;
gst_message_parse_error (msg, &err, NULL);
g_print ("ERROR: %s\n", err->message);
g_error_free (err);
gst_message_unref (msg);
}
return -1;
}
但我得到的错误,当我尝试去codeR连接到转换器。为什么它工作正常使用命令行,但不与C code吗?
But I get error when I try to connect the decoder to the converter. Why it works fine with the command line but not with C code?
推荐答案
德codeBIN使用一种叫做有时垫,这基本上是一个垫,将显示当特定条件得到满足,在去codebins情况下是媒体的存在去codeD。 GST推出会做这样的事情自动的,但在code,你需要注册一个回调,然后在回调链接垫。另请参阅:的GStreamer:如何连接动态垫
Decodebin uses something called a "sometimes-pad", which is basically a pad that will show up when a certain condition is met, in decodebins case that is media being decoded. gst-launch will do this sort of thing automagically, but in code you need to register a callback, and then link the pad in that callback. See also: GStreamer: how to connect dynamic pads
这篇关于Gstreamer1.0:链接去codeBIN到videoconvert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!