【发布时间】:2021-04-01 08:39:31
【问题描述】:
我正在编写一个 gstreamer 插件来在高清视频帧上渲染相机视频(高度=480,宽度=640,格式 UYVY)。在我的链函数 (gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)) 中,我可以看到 buf 大小为 480x640x2。我分配了一个相当于全高清的新缓冲区,并将这个 UYVY 数据复制到新缓冲区的顶部并替换了现有缓冲区。但是输出视频仍然是 height=480, width=640。
这里是代码sn-p。
gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstPluginTemplate *filter;
GstMapInfo map;
guchar *data;
gint width = 640, height = 480;
GstMemory *mem;
int row = 0;
filter = GST_PLUGIN_TEMPLATE (parent);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
mem = gst_allocator_alloc(NULL, 4147200, NULL); //1080*1920*2 (Full HD UYVY) = 4147200
GstMapInfo info_out;
gst_memory_map(mem, &info_out, GST_MAP_WRITE);
for(int i = 0; i < 480 ; i++) {
memcpy(info_out.data + row, map.data + row, 1280);
row += 1280; //640*2
}
gst_buffer_replace_all_memory(buf, mem);
gst_buffer_unmap (buf, &map);
gst_memory_unmap(mem, &info_out);
return gst_pad_push (filter->srcpad, buf);
}
【问题讨论】:
-
我添加了 belwo sn-p 但在 kmssink 0:00:01.844010270 1800 0x5594e05600 错误 kmssink gstkmssink.c:1147:gst_kms_sink_stop:
无法恢复以前的 CRTC 模式:否这样的文件或目录 GstCaps * caps = gst_caps_from_string("video/x-raw, format=UYVY, width=640, height=480"); gst_pad_push_event (filter->srcpad, gst_event_new_caps(caps));