<div dir="ltr">Fwd..</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Oct 2023 at 19:35, Sulthan Amanu <<a href="mailto:sulthan4380@gmail.com">sulthan4380@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Team,<br><br>I have encountered an issue while attempting to convert an H264 encoded buffer to an MP4 file using the appsrc element. Unfortunately, I am unable to successfully perform this conversion, and I have attached the relevant pipeline and code snippet for your reference:<br><br><b>Pipeline:</b><br><br>gst-launch-1.0 -e v4l2src device="/dev/video0" ! videoconvert ! queue ! x264enc tune=zerolatency ! identity ! fakesink<br><br><br>I'm utilizing the `identity` element to capture the buffers and store them in a buffer list. Subsequently, I am using the following code snippet to convert the H264 encoded buffer to an MP4 file:<br><br><b>Code Snippet:</b><br><br>void convertToMP4(GstBufferList *buflist)<br>{<br> // Create pipeline for MP4 conversion.<br> GstElement *pipeline, *appsrc, *videoconvert, *x264enc, *h264parse, *videoencode, *muxer, *file_sink;<br> pipeline = gst_pipeline_new("MP4-pipeline");<br> appsrc = gst_element_factory_make("appsrc", "source");<br> h264parse = gst_element_factory_make("h264parse", "app-h264parse");<br> muxer = gst_element_factory_make("mp4mux", "mux");<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> g_object_set(muxer, "fragment-duration", 2000, NULL);<br> // g_object_set(h264parse, "config-interval", -1, NULL);<br> // g_object_set(x264enc, "tune", 4, NULL);<br><br> // Set the resolution and framerate caps<br> GstCaps *caps = gst_caps_new_simple("video/x-h264",<br> "stream-format", G_TYPE_STRING, "byte-stream",<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_AUDIO.mp4", NULL);<br><br> gst_bin_add_many(GST_BIN(pipeline), appsrc, h264parse, muxer, file_sink, NULL);<br> if (gst_element_link_many(appsrc, h264parse, muxer, 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> // Set the pipeline to the PLAYING state.<br> gst_element_set_state(pipeline, GST_STATE_PLAYING);<br><br> // Push video and audio buffers into appsrc.<br> GstFlowReturn retval = gst_app_src_push_buffer_list(GST_APP_SRC(appsrc), copy_buflist);<br> if (retval != GST_FLOW_OK) {<br> g_printerr("Error pushing buffers to appsrc: %s\n", gst_flow_get_name(retval));<br> // Handle error and cleanup if needed.<br> }<br><br> bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));<br> gst_bus_add_signal_watch(bus);<br> g_signal_connect(bus, "message::error", G_CALLBACK(cb_message_error), NULL);<br> g_signal_connect(bus, "message::eos", G_CALLBACK(cb_message_eos), NULL);<br>}<br><br>However, I am encountering the following error:<br><br><br><b>ERROR</b><br><br>is buffered is filled, and the Buffer size is 70<br><br>MP4 converted /n0:00:08.391637077 18811 0x7fcd6c0040f0 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:<source:src> Creating a random stream-id; consider implementing a deterministic way of creating a stream-id<br><br>I kindly request your assistance in resolving this issue promptly. Your guidance in rectifying this problem will be greatly appreciated.<br><br>Best Regards,<br>Sulthan<br></div>
</blockquote></div>