我正在尝试模拟C中的以下gstreamer管道。我想使用网站上的图片而不是视频。
gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \
videotestsrc pattern=1 ! video/x-raw-yuv,framerate=5/1,width=320,height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. \
videotestsrc pattern=15 ! video/x-raw-yuv,framerate=5/1,width=320,height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. \
videotestsrc pattern=13 ! video/x-raw-yuv,framerate=5/1,width=320,height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. \
videotestsrc pattern=0 ! video/x-raw-yuv,framerate=5/1,width=320,height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. \
videotestsrc pattern=3 ! video/x-raw-yuv,framerate=5/1,width=640,height=360 ! mix.
所以这是我的代码的摘录(我只尝试了两张图片):
void display_logo (struct Radio radio[]){
GMainLoop *loop;
GstElement *pipeline,*freeze,*clrspace;
GstElement *source[2];
GstElement *videobox1,*videobox2;
GstElement *mixer,*sink,*queuevideo;
GstBus *bus;
loop = g_main_loop_new (NULL, FALSE);
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("player");
source[0] = gst_element_factory_make ("playbin2", "dec1");
source[1] = gst_element_factory_make ("playbin2", "dec2");
freeze = gst_element_factory_make ("imagefreeze", "fr");
//videobox1 = gst_element_factory_make ("videobox", "videobox1");
//videobox2 = gst_element_factory_make ("videobox", "videobox2");
clrspace = gst_element_factory_make ("ffmpegcolorspace", "clrspace");
mixer = gst_element_factory_make ("videomixer", "mixer");
queuevideo = gst_element_factory_make ("queue", "queue-video");
sink = gst_element_factory_make ("autovideosink", "sink");
if (!pipeline || !source[0] || source[1] !sink || !mixer ||!freeze || !clrspace ||!queuevideo ) {
g_printerr ("One element could not be created. Exiting.\n");
exit(1);
}
g_object_set (source[0], "uri", radio[0].logo, NULL);
g_object_set (source[1], "uri", radio[1].logo, NULL);
// g_object_set(videobox1,"border-alpha",0,"top",0,"left",0,NULL);
// g_object_set(videobox2,"border-alpha",0,"top",0,"left",-200,NULL);
/* we add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* we add all elements into the pipeline */
gst_bin_add_many (GST_BIN (pipeline),
source[0],mixer, clrspace, freeze, sink, source[1], NULL);
/* we link the elements together */
gst_element_link_many (source[0], mixer, clrspace, freeze,sink,source[1], NULL);
//gst_element_link_many (source[1], mixer, NULL);
g_signal_connect (source[0], "pad-added", G_CALLBACK (on_pad_added), queuevideo);
g_signal_connect (source[1], "pad-added", G_CALLBACK (on_pad_added), queuevideo);
/* Set the pipeline to "playing" state*/
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_print ("Running...\n");
g_main_loop_run (loop);
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
}
当我运行代码时,我有3个窗口(1个绿色,2个带有图片)。我尝试使用视频,但它没有改变任何东西。如何在同一窗口中显示两张图片?
答案 0 :(得分:0)
所以基本上你想要合成图像,即给定图像1 2 3 4产生这个图像,例如所有图像,你可以发布更多细节,以帮助你在Radio结构中有你的东西吗?因为我不显示代码中的图片网址