【发布时间】:2019-07-03 08:43:42
【问题描述】:
我正在使用 Xilinx Petalinux 和 Vivado 2018.2 工具,目标是带有(视频编解码器单元)VCU 的 Zynqmp 设备。
我正在 Vivado SDK 中开发基于 gstreamer 的应用程序,目标是构建下一个管道:
- 从 USB3 相机捕获 RAW 视频帧(不能使用 v4l2,它使用 它自己的 API 来捕获帧)。将帧包装到 GstBuffer 并将其推送到 appsrc 管道元素。
- 使用硬件 VCU (H.264/H.265) 压缩视频。 (omxh264enc)
- 将其保存到文件中。 (文件接收器)
目前我能够连接相机,获取帧并将它们包装在 GstBuffer 类型中。
问题是生成的“output.h264”文件是空的。
代码的相关部分是:
/* Create pipeline */
pipeline = gst_parse_launch("appsrc is-live=TRUE name=xsource caps= video/x-raw,format=Y800,width=1280,height=1024 ! omxh264enc ! filesink location= media/test/output.h264", NULL);
if(!pipeline)
goto finish;
/* we add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, NULL);
gst_object_unref (bus);
appsrc=gst_bin_get_by_name(GST_BIN(pipeline), "xsource");
gst_element_set_state(pipeline, GST_STATE_PLAYING);
if(xiGetImage(xiH, 5000, &image) == XI_OK) //Get just one frame
{
unsigned long buffer_size = image.width*image.height;
buffer = gst_buffer_new();
gst_buffer_insert_memory(buffer, -1, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, (guint8*)image.bp, buffer_size, 0, buffer_size, NULL, NULL));
ret = gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);
if(ret != GST_FLOW_OK){
break;
}
}
gst_app_src_end_of_stream(GST_APP_SRC(appsrc));
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
我检查了(在 SDK 调试模式下)内存和缓冲区不是空的,因此 appsrc 的相机接口和缓冲区推送方法似乎工作正常。我怀疑问题可能出在管道链定义中,但我尝试了很多配置都没有成功......
任何想法/线索将不胜感激。
编辑:
按照建议,我尝试在代码末尾等待 EOS 确认和错误消息检查:
gst_app_src_end_of_stream(GST_APP_SRC(appsrc));
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg =
gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
我还尝试加载更多帧以查看是否有帮助,我尝试像这样加载 500:
while(xiGetImage(xiH, 5000, &image) == XI_OK)
{
unsigned long buffer_size = image.width*image.height;
buffer = gst_buffer_new();
gst_buffer_insert_memory(buffer, -1, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, (guint8*)image.bp, buffer_size, 0, buffer_size, NULL, NULL));
ret = gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);
if(ret != GST_FLOW_OK){
break;
}
if(frames > 500)
{
break;
}else{
frames++;
}
}
但不幸的是它没有帮助,仍然有空文件并且没有错误。
还有什么想法/线索?
谢谢。
【问题讨论】:
-
嗨,我也在尝试这样做。但是,当我包含 gst.h 时,我会收到几个文件丢失错误。请告诉我您在 petalinux 构建中包含的所有软件包。
标签: video gstreamer h.264 zynq h.265