gst-launch-0.10 v4l2src device=/dev/video0 ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=320,height=240,frame=25/1 ! ffmpegcolorspace ! videorate ! video/x-raw-yuv,framerate=10/1 ! clockoverlay ! ffenc_mpeg4 ! udpsink host=127.0.0.1 port=5000
我正在使用gstreamer-0.10编写程序,基于上面显示的gstreamer-0.10命令。
有几件事我完全无能为力。
1) 如何使用clockoverlay 并将其添加到管道中?我知道它的过滤器,但无法找到它的例子吗?
2) 在哪里正确添加视频分享上限 。我的意思是,我在ffmpegcolourspace元素之后添加,它工作正常。为了好奇,我在ffenc_mpeg4元素之后添加它并再次正常工作。在这两种情况下我都可以看到实时视频。是否有可能我根本不在管道中添加它。有人可以请教我。下面是我的代码片段。
source = gst_element_factory_make ("v4l2src", "source");
// cap filter #1
GstElement *capsfilter = gst_element_factory_make("capsfilter", "camera_caps");
GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)YUY2,width=320,height=240,framerate=25/1");
g_object_set (capsfilter, "caps", caps, NULL);
conv = gst_element_factory_make("ffmpegcolorspace", "Colorconverter");
// capfilter #2
GstElement *capsfilterColor = gst_element_factory_make("capsfilter", "video-rate");
GstCaps *capsColor = gst_caps_from_string ("videorate ! video/x-raw-yuv,framerate=10/1");
g_object_set ( capsfilterColor, "caps", capsColor, NULL);
videoenc = gst_element_factory_make("ffenc_mpeg4", "videoenc");
udpsink = gst_element_factory_make("udpsink", "udpsink");
// Create the empty pipeline
pipeline = gst_pipeline_new ("test-pipeline");
g_object_set(G_OBJECT(udpsink),
"host", "127.0.0.1",
"port", 5000,
NULL);
g_object_set (G_OBJECT ( source ), "device", "/dev/video0", NULL);
gst_bin_add_many (GST_BIN (pipeline), source, capsfilter, conv, capsfilterColor, videoenc, udpsink, NULL);
// **here AM I adding caps filter correctly??**?
gst_element_link_many (source, capsfilter, conv, capsfilterColor, videoenc, udpsink, NULL);
答案 0 :(得分:3)
1,添加时钟覆盖只是把它放在v4l2src之后的某个地方(也许它已经在你已经拥有它的地方).. clockoverlay只是v4l2src或videorate的另一个元素..
这也有效(我没有安装0.10,但它应该可以工作):
gst-launch-1.0 videotestsrc ! clockoverlay ! autovideosink
2,对于代码 - 它非常混乱,你将元素混合在一起。您必须了解capsfilter是在前一个元素的输出上施加某种格式的元素。实际上限设置为capsfilter作为属性(在v4l2src上设置属性如设备等..在capsfilter上设置属性称为caps
,其中包含表示这些功能的字符串。)
你不能以这种方式将视频内容放入大写字母...视频比例是元素,大写字母是属性..
你必须创建videorate并在它之后添加capsfilter ..这样videorate会将视频流转换为它在src pad上看到的所需速率(videorate的输出)。
所以代码如下。 对不起,我无法重新整理一下,也将capfilterColor重命名为capsfilterRate,因为这更合适。 我还没有测试过 - 只是写在我的头上,我希望它会编译:D
source = gst_element_factory_make ("v4l2src", "source"); GstElement *capsfilter = gst_element_factory_make("capsfilter", "camera_caps"); conv = gst_element_factory_make("ffmpegcolorspace", "Colorconverter"); videorate = gst_element_factory_make("videorate", "videorate-element"); GstElement *capsfilterRate = gst_element_factory_make("capsfilter", "video-rate"); videoenc = gst_element_factory_make("ffenc_mpeg4", "videoenc"); udpsink = gst_element_factory_make("udpsink", "udpsink"); // cap filter #1 GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)YUY2,width=320,height=240,framerate=25/1"); g_object_set (capsfilter, "caps", caps, NULL); gst_caps_unref(caps);//do not forget to unref - memoryleak! // capfilter #2 GstCaps *capsRate = gst_caps_from_string ("video/x-raw-yuv,framerate=10/1"); g_object_set ( capsfilterRate, "caps", capsRate, NULL); gst_caps_unref(capsRate);//again unref! // Create the empty pipeline pipeline = gst_pipeline_new ("test-pipeline"); g_object_set(G_OBJECT(udpsink), "host", "127.0.0.1", "port", 5000, NULL); g_object_set (G_OBJECT ( source ), "device", "/dev/video0", NULL); //proper adding to pipe gst_bin_add_many (GST_BIN (pipeline), source, capsfilter, conv, videorate, capsfilterRate, videoenc, udpsink, NULL); //proper linking: gst_element_link_many (source, capsfilter, conv, videorate, capsfilterRate, videoenc, udpsink, NULL);