<div dir="auto">Any update regarding to my query ?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 6, 2023, 20:54 Sulthan Amanu <<a href="mailto:sulthan4380@gmail.com">sulthan4380@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Team,<br><br>I'm attempting to convert a raw buffer into an MP4 format using an appsrc. However, I encountered a problem with frame loss during the conversion of a list of buffers. For instance, I have a list of 150 frames with a frame rate of 10 frames per second (fps), but the resulting MP4 file only contains 13 seconds of video. This means that 2 seconds worth of frames (20 frames) have been lost during the conversion process. Below, you'll find the code for my conversion logic:<br><br>CODE:<br><br>void convertToMP4(GstBufferList *buflist)<br>{<br> // Create pipeline for MP4 conversion.<br> GstElement *pipeline, *appsrc, *videoconvert, *videoencode, *muxer, *file_sink;<br> guint64 timestamp_ns = 0; // Initialize with zero or the desired start time in nanoseconds<br> guint frame_duration_ns = GST_SECOND / 10; // 10 frames per second (10 FPS)<br> pipeline = gst_pipeline_new("MP4-pipeline");<br> appsrc = gst_element_factory_make("appsrc", "source");<br> file_sink = gst_element_factory_make("filesink", "filesink");<br><br> g_object_set(G_OBJECT(appsrc),<br> "stream-type", 0,<br> "format", GST_FORMAT_TIME, NULL);<br><br> // Set the resolution and framerate caps<br> // GstCaps *caps = gst_caps_new_simple("video/x-raw",<br> // "width", G_TYPE_INT, 1280,<br> // "height", G_TYPE_INT, 720,<br> // "framerate", GST_TYPE_FRACTION, 10, 1,<br> // NULL);<br> <br> // gst_app_src_set_caps (GST_APP_SRC(appsrc),caps);<br><br> // gst_caps_unref(caps);<br><br> g_object_set(file_sink, "location", "DIA_VIDEO.mp4", NULL);<br><br> gst_bin_add_many(GST_BIN(pipeline), appsrc, file_sink, NULL);<br> if (gst_element_link_many(appsrc, file_sink, NULL) != TRUE)<br> {<br> g_printerr("Elements could not be linked in the pipeline.\n");<br> gst_object_unref(pipeline);<br> exit(1);<br> }<br><br> copy_buflist = gst_buffer_list_copy_deep(buflist);<br> g_print("isbuffered is filled and Buffer size is %d\n", gst_buffer_list_length(copy_buflist));<br> gst_element_set_state(pipeline, GST_STATE_PLAYING);<br><br> for (int frame_number = 0; frame_number < gst_buffer_list_length(copy_buflist); frame_number++) {<br> GstBuffer *buffer = gst_buffer_list_get(copy_buflist, frame_number);<br><br> // Set the timestamp for the buffer<br> GST_BUFFER_TIMESTAMP(buffer) = timestamp_ns;<br><br> // Increment the timestamp for the next frame<br> timestamp_ns += frame_duration_ns;<br><br> // Push the buffer into the pipeline<br> gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);<br> }<br><br> // retval = gst_app_src_push_buffer_list(GST_APP_SRC(appsrc), copy_buflist);<br> g_print("RETVAL %d\n", retval);<br> g_print("Sending EOS!!!!!!!");<br> g_signal_emit_by_name(appsrc, "end-of-stream", &retval);<br>}<br><br>Can you please provide a solution on my problem.<br><br>Regards,<br><br>Sulthan</div>
</blockquote></div>