【问题标题】:[gstreamer ]How to change the video resolution from gstplugin[gstreamer]如何从 gstplugin 更改视频分辨率
【发布时间】: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));

标签: gstreamer gstreamer-1.0


【解决方案1】:

您需要向下游发送一个新的 CAPS 事件。可能您想要gst_event_new_caps() 并将其推过源板。但是请仔细检查文档,了解您到底想要什么。

【讨论】:

    【解决方案2】:

    感谢 Florian Zwoch 的支持。添加以下更改后,它现在可以工作了。

    从 gst_my_filter_sink_event 调用自定义 gst_my_filter_setcaps(过滤器,大写)。

    【讨论】:

      猜你喜欢
      • 2016-03-27
      • 2020-11-14
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多