I'm working with Xilinx Petalinux and Vivado 2018.2 tools targeting a Zynqmp device with a (video codec unit) VCU.
I'm developing a gstreamer based application in Vivado SDK where the goal is to construct the next pipeline:
- Capture RAW video frames from a USB3 camera (can't use v4l2, it uses its own API to capture the frames). Wrap frames to GstBuffer and push it to appsrc pipeline element.
- Compress the video using the hardware VCU (H.264/H.265). (omxh264enc)
- Save it to a file. (filesink)
At the moment I'm able to interface the camera, get the frames and wrap them in a GstBuffer type.
The problem is that the generated "output.h264" file is empty.
The relevant part of the code is:
/* 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));
I checked (on SDK debug mode) the memory and buffers are not empty, so the camera interface and buffer push method to appsrc seems to be working fine. I suspect that the issue might be in the pipeline chain definition but I tried lot of configurations without success...
Any ideas/clues would be appreciated.
EDIT:
As suggested, I tried to wait for EOS confirmation and an error message check at the end of the code:
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));
Also I tried to load more frames to see if that helps, I tried to load 500 like so:
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++;
}
}
But unfortunately it didn't help, still having empty file and no errors.
Any more ideas/clues?
Thanks.