Why would videoencoder handle_frame only ever be called once?
Graham Leggett
minfrin at sharp.fm
Sun Sep 6 07:49:39 PDT 2015
Hi all,
I am trying to convert a video frame into text metatdata (printing the time), and have created a videoencoder element in an effort to do this.
I have implemented a set_format() and handle_frame() function, and they are called as below. set_format is called once, and handle_frame() is called once, and then nothing follows. There are no warnings, and no errors.
I am expecting handle_frame() to be called once per frame, is this correct?
Redistribute latency...
0:00:09.027681221 29059 0x22b8f0 DEBUG xxx gstxxx.c:258:gst_xxx_set_format:<xxx0> set_format
0:00:09.028384236 29059 0x22b8f0 DEBUG xxx gstxxx.c:313:gst_xxx_handle_frame:<xxx0> handle_frame
************ handle_frame
[New Thread 0x69379470 (LWP 29083)]
I am currently creating a 64 byte buffer and writing it as follows. This is wired into filesink, which then creates a zero byte file and I never see any data written. Can anyone see where I am going wrong?
static GstFlowReturn
gst_xxx_handle_frame (GstVideoEncoder * encoder,
GstVideoCodecFrame * frame)
{
Gstxxx *xxx = GST_xxx (encoder);
GstVideoFrame vframe;
GstMemory *output_mem;
GstMapInfo output_map;
static GstAllocationParams params = { 0, 7, 0, 0, };
gsize desired_size;
GST_DEBUG_OBJECT (xxx, "handle_frame");
if (!gst_video_frame_map (&vframe,
&xxx->input_state->info, frame->input_buffer, GST_MAP_READ))
goto invalid_frame;
desired_size = 64;
output_mem = gst_allocator_alloc (NULL, desired_size, ¶ms);
gst_memory_map (output_mem, &output_map, GST_MAP_READWRITE);
output_map.data[0] = 'f';
output_map.data[1] = 'o';
output_map.data[2] = 'o';
output_map.data[3] = '\n';
output_map.data[4] = 0;
gst_memory_unmap (output_mem, &output_map);
frame->output_buffer = gst_buffer_new ();
gst_buffer_copy_into (frame->output_buffer, frame->input_buffer,
GST_BUFFER_COPY_METADATA, 0, -1);
gst_buffer_append_memory (frame->output_buffer, output_mem);
output_mem = NULL;
gst_video_frame_unmap (&vframe);
printf("************ handle_frame\n");
GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
return gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (xxx),
frame);
// return GST_FLOW_OK;
invalid_frame:
{
GST_WARNING_OBJECT (xxx, "invalid frame received");
return gst_video_encoder_finish_frame (encoder, frame);
}
}
Regards,
Graham
—
More information about the gstreamer-devel
mailing list