Data loss in Buffer to mp4 file conversion

Sulthan Amanu sulthan4380 at gmail.com
Thu Sep 14 04:12:46 UTC 2023


Please reply to my query, I am waiting for your reply at long time

Regards,
Sulthan

On Mon, Sep 11, 2023, 00:25 Sulthan Amanu <sulthan4380 at gmail.com> wrote:

> Any update regarding to my query ?
>
> On Wed, Sep 6, 2023, 20:54 Sulthan Amanu <sulthan4380 at gmail.com> wrote:
>
>> Hi Team,
>>
>> 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:
>>
>> CODE:
>>
>> void convertToMP4(GstBufferList *buflist)
>> {
>>     // Create pipeline for MP4 conversion.
>>     GstElement *pipeline, *appsrc, *videoconvert, *videoencode, *muxer,
>> *file_sink;
>>     guint64 timestamp_ns = 0; // Initialize with zero or the desired
>> start time in nanoseconds
>>     guint frame_duration_ns = GST_SECOND / 10; // 10 frames per second
>> (10 FPS)
>>     pipeline = gst_pipeline_new("MP4-pipeline");
>>     appsrc = gst_element_factory_make("appsrc", "source");
>>     file_sink = gst_element_factory_make("filesink", "filesink");
>>
>>     g_object_set(G_OBJECT(appsrc),
>>                  "stream-type", 0,
>>                  "format", GST_FORMAT_TIME, NULL);
>>
>>     // Set the resolution and framerate caps
>>     // GstCaps *caps = gst_caps_new_simple("video/x-raw",
>>     //     "width", G_TYPE_INT, 1280,
>>     //     "height", G_TYPE_INT, 720,
>>     //     "framerate", GST_TYPE_FRACTION, 10, 1,
>>     //     NULL);
>>
>>     // gst_app_src_set_caps (GST_APP_SRC(appsrc),caps);
>>
>>     // gst_caps_unref(caps);
>>
>>     g_object_set(file_sink, "location", "DIA_VIDEO.mp4", NULL);
>>
>>     gst_bin_add_many(GST_BIN(pipeline), appsrc, file_sink, NULL);
>>     if (gst_element_link_many(appsrc, file_sink, NULL) != TRUE)
>>     {
>>         g_printerr("Elements could not be linked in the pipeline.\n");
>>         gst_object_unref(pipeline);
>>         exit(1);
>>     }
>>
>>     copy_buflist = gst_buffer_list_copy_deep(buflist);
>>     g_print("isbuffered is filled and Buffer size is %d\n",
>> gst_buffer_list_length(copy_buflist));
>>     gst_element_set_state(pipeline, GST_STATE_PLAYING);
>>
>>     for (int frame_number = 0; frame_number <
>> gst_buffer_list_length(copy_buflist); frame_number++) {
>>          GstBuffer *buffer = gst_buffer_list_get(copy_buflist,
>> frame_number);
>>
>>         // Set the timestamp for the buffer
>>         GST_BUFFER_TIMESTAMP(buffer) = timestamp_ns;
>>
>>         // Increment the timestamp for the next frame
>>         timestamp_ns += frame_duration_ns;
>>
>>         // Push the buffer into the pipeline
>>         gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);
>>     }
>>
>>    // retval = gst_app_src_push_buffer_list(GST_APP_SRC(appsrc),
>> copy_buflist);
>>     g_print("RETVAL %d\n", retval);
>>     g_print("Sending EOS!!!!!!!");
>>     g_signal_emit_by_name(appsrc, "end-of-stream", &retval);
>> }
>>
>> Can you please provide a solution on my problem.
>>
>> Regards,
>>
>> Sulthan
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230914/26cddc69/attachment-0001.htm>


More information about the gstreamer-devel mailing list