<div dir="ltr">I've made for you very simple application which you can use to reproduce the problem. It takes the video stream as a source, decodes it, encodes it into mpeg2, mux it into mpegts container, saves it to file. you can use any video file as a source. As the file reaches the end pipeline receives EOS event, at the event I try to set pipeline to GST_STATE_READY, it causes a crash. Here's complete code below. I will try to give you backtrace with gdb later.<div><br></div><div><div>typedef struct _CustomData {</div><div> //GstElement *pipeline;</div><div> GstElement *source;</div><div> GstElement *convert;</div><div> GstElement *q;</div><div> GstElement *q1;</div><div> GstElement *sink;</div><div> GstElement *filter;</div><div> GstCaps *filtercaps;</div><div>} CustomData;</div><div><br></div><div>static CustomData data;</div><div><br></div><div>GstElement *pipeline;</div><div>GstElement *ebin;</div><div>GstEncodingProfile *prof;</div><div><br></div><div>GstBus *bus;</div><div>GstMessage *msg;</div><div>GstStateChangeReturn ret;</div><div><br></div><div>GstPadLinkReturn res;</div><div>GMainLoop *loop;</div><div><br></div><div>gchar *format= "video/mpegts,systemstream=True,packetsize=188";</div><div>gchar *aformat= "audio/mpeg, mpegversion=(int)4, rate=(int)16000, stream-format=(string)adts, base-profile=(string)lc, bitrate=(int)192"; //audio/x-ac3";</div><div>gchar *vformat= "video/mpeg,mpegversion=2,systemstream=False, bitrate=(int)7500";//"video/x-h264";</div><div><br></div><div><br></div><div>static GstEncodingProfile *</div><div>create_profile (GstCaps * cf, GstCaps * vf, GstCaps * af)</div><div>{</div><div> GstEncodingContainerProfile *cprof = NULL;</div><div> GstEncodingProfile * vtmp = NULL;</div><div><br></div><div> cprof = gst_encoding_container_profile_new ((gchar *) "test-application-profile", NULL, cf, NULL);</div><div><br></div><div> if (vf)</div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre"> </span> vtmp = (GstEncodingProfile *) gst_encoding_video_profile_new (vf, NULL, NULL, 0);</div><div><span class="" style="white-space:pre"> </span> gst_encoding_container_profile_add_profile (cprof, vtmp);</div><div><span class="" style="white-space:pre"> </span>}</div><div><br></div><div> if (af)</div><div> gst_encoding_container_profile_add_profile (cprof, (GstEncodingProfile *)</div><div> gst_encoding_audio_profile_new (af, NULL, NULL, 0));</div><div><br></div><div> /* print out some info */</div><div> {</div><div> gchar *desc = gst_pb_utils_get_codec_description (cf);</div><div> gchar *cd = gst_caps_to_string (cf);</div><div> g_print ("Encoding parameters\n");</div><div> g_print (" Container format : %s (%s)\n", desc, cd);</div><div> g_free (desc);</div><div> g_free (cd);</div><div> if (vf) {</div><div> desc = gst_pb_utils_get_codec_description (vf);</div><div> cd = gst_caps_to_string (vf);</div><div> g_print (" Video format : %s (%s)\n", desc, cd);</div><div> g_free (desc);</div><div> g_free (cd);</div><div> }</div><div> if (af) {</div><div> desc = gst_pb_utils_get_codec_description (af);</div><div> cd = gst_caps_to_string (af);</div><div> g_print (" Audio format : %s (%s)\n", desc, cd);</div><div> g_free (desc);</div><div> g_free (cd);</div><div> }</div><div> }</div><div><br></div><div> return (GstEncodingProfile *) cprof;</div><div>}</div><div><br></div><div>static GstEncodingProfile *</div><div>create_profile_from_string (gchar * format, gchar * vformat, gchar * aformat)</div><div>{</div><div> GstEncodingProfile *prof = NULL;</div><div> GstCaps *cf = NULL, *vf = NULL, *af = NULL;</div><div><br></div><div> if (format)</div><div> cf = gst_caps_from_string (format);</div><div> if (vformat)</div><div> vf = gst_caps_from_string (vformat);</div><div> if (aformat)</div><div> af = gst_caps_from_string (aformat);</div><div><br></div><div> if (G_UNLIKELY ((vformat && (vf == NULL)) || (aformat && (af == NULL))))</div><div> goto beach;</div><div><br></div><div> prof = create_profile (cf, vf, af);</div><div><br></div><div>beach:</div><div> if (cf)</div><div> gst_caps_unref (cf);</div><div> if (vf)</div><div> gst_caps_unref (vf);</div><div> if (af)</div><div> gst_caps_unref (af);</div><div><br></div><div> return prof;</div><div>}</div><div><br></div><div>gboolean bus_call(GstBus *bus, GstMessage *msg, void *data) </div><div> { </div><div> gchar *debug; </div><div> GError *err; </div><div> GMainLoop *loop = (GMainLoop*)data; </div><div> switch (GST_MESSAGE_TYPE(msg)) </div><div> { </div><div> case GST_MESSAGE_EOS: </div><div> g_print("EOS received on OBJ NAME %s\n",GST_OBJECT_NAME(msg->src)); </div><div> //g_main_loop_quit (loop); </div><div><span class="" style="white-space:pre"> </span>gst_element_set_state (pipeline, GST_STATE_READY);</div><div><span class="" style="white-space:pre"> </span> gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div> break; </div><div> case GST_MESSAGE_ERROR: </div><div> gst_message_parse_error(msg, &err, &debug); </div><div> g_free(debug); </div><div> g_print("BUS CALL %s\n", err->message); </div><div> g_error_free(err); </div><div> g_main_loop_quit (loop); </div><div> break;</div><div> default: </div><div> break; </div><div> } </div><div> return TRUE; </div><div> } </div><div><br></div><div>/* This function will be called by the pad-added signal */</div><div>static void pad_added_handler (GstElement *src, GstPad *new_pad, GstElement *sink) {</div><div> GstPad *gsink_pad = gst_element_get_static_pad (sink, "sink");</div><div> GstPadLinkReturn ret;</div><div> GstCaps *new_pad_caps = NULL;</div><div> GstStructure *new_pad_struct = NULL;</div><div> const gchar *new_pad_type = NULL;</div><div> </div><div> g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src));</div><div> </div><div> /* Check the new pad's type */</div><div> new_pad_caps = gst_pad_query_caps (new_pad, NULL);</div><div> new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);</div><div> new_pad_type = gst_structure_get_name (new_pad_struct);</div><div> if (!g_str_has_prefix (new_pad_type, "video/x-raw") && !g_str_has_prefix (new_pad_type, "audio/x-raw")) {<span class="" style="white-space:pre"> </span></div><div> g_print (" It has type '%s' which is not raw video or audio. Ignoring.\n", new_pad_type);</div><div> goto exit;</div><div> }</div><div><br></div><div> if (g_str_has_prefix (new_pad_type, "video/x-raw"))</div><div> {<span class="" style="white-space:pre"> </span> </div><div><span class="" style="white-space:pre"> </span> ret = gst_pad_link (new_pad, gsink_pad);<span class="" style="white-space:pre"> </span> </div><div> }</div><div> else</div><div> {<span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span> return;<span class="" style="white-space:pre"> </span></div><div> }</div><div> </div><div> if (GST_PAD_LINK_FAILED (ret)) {</div><div> g_print (" Type is '%s' but link failed.\n", new_pad_type);</div><div> } else {</div><div> g_print (" Link succeeded (type '%s').\n", new_pad_type);</div><div> }</div><div> </div><div>exit:</div><div> /* Unreference the new pad's caps, if we got them */</div><div> if (new_pad_caps != NULL)</div><div> gst_caps_unref (new_pad_caps);</div><div> </div><div> /* Unreference the sink pad */</div><div> gst_object_unref (gsink_pad);</div><div>}</div><div><br></div><div>int</div><div>main (int argc,</div><div>char *argv[])</div><div>{</div><div><span class="" style="white-space:pre"> </span>gst_init (&argc, &argv);</div><div> </div><div> g_print ("gstreamer initialized.\n");</div><div> /* Create the elements */</div><div> data.source = gst_element_factory_make ("uridecodebin", "source");</div><div> data.convert = gst_element_factory_make ("videoscale", "convert");</div><div> data.q = gst_element_factory_make ("queue", "q");</div><div> data.q1 = gst_element_factory_make ("queue", "q1");</div><div> data.sink = gst_element_factory_make ("filesink", "sink");</div><div> g_object_set (G_OBJECT (data.sink), "location", "c:\\tmp\\channel.ts", NULL);</div><div> data.filter = gst_element_factory_make("capsfilter","filter");</div><div> data.filtercaps = gst_caps_new_simple ("video/x-raw",</div><div><span class="" style="white-space:pre"> </span> "format", G_TYPE_STRING, "I420", </div><div><span class="" style="white-space:pre"> </span>"width", G_TYPE_INT, 854,</div><div><span class="" style="white-space:pre"> </span>"height", G_TYPE_INT, 480,</div><div><span class="" style="white-space:pre"> </span>NULL);</div><div> g_object_set (G_OBJECT (data.filter), "caps", data.filtercaps, NULL);</div><div><br></div><div> g_print ("starting profile initialization\n");</div><div><br></div><div><span class="" style="white-space:pre"> </span>/* Create the profile */</div><div> prof = create_profile_from_string (format, vformat, aformat);</div><div> if (G_UNLIKELY (prof == NULL)) {</div><div> g_print ("Encoding arguments are not valid !\n");</div><div> return -1;</div><div> }</div><div><br></div><div><span class="" style="white-space:pre"> </span>/* Create the encodebin */</div><div><span class="" style="white-space:pre"> </span>ebin = gst_element_factory_make ("encodebin", NULL);</div><div> g_object_set (ebin, "profile", prof, NULL); </div><div> </div><div> /* Create the empty pipeline */</div><div> pipeline = gst_pipeline_new ("test-pipeline");</div><div><br></div><div> loop = g_main_loop_new (NULL, FALSE);</div><div> </div><div> if (!pipeline || !data.source || !data.q || !data.sink) {</div><div> g_printerr ("Not all elements could be created.\n");</div><div> return -1;</div><div> }</div><div> </div><div> /* Build the pipeline. */</div><div> gst_bin_add_many (GST_BIN (pipeline), data.source, data.q,data.convert, data.filter, ebin, data.q1, data.sink, NULL);</div><div> if (!gst_element_link_many (data.q, data.convert, data.filter, ebin, data.q1, data.sink, NULL)) {</div><div> g_printerr ("Elements could not be linked.\n");</div><div> gst_object_unref (pipeline);</div><div> return -1;</div><div> }</div><div> </div><div> /* Set the URI to play */</div><div> g_object_set (data.source, "uri", "<a href="http://www.quebec511.info/diffusion/fr/camera/camera.ashx?format=mp4&id=3505">http://www.quebec511.info/diffusion/fr/camera/camera.ashx?format=mp4&id=3505</a>", NULL);</div><div> </div><div> /* Connect to the pad-added signal */</div><div> g_signal_connect (data.source, "pad-added", G_CALLBACK (pad_added_handler), data.q);</div><div> </div><div> /* we add a message handler */</div><div><span class="" style="white-space:pre"> </span>bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));</div><div><span class="" style="white-space:pre"> </span>gst_bus_add_watch (bus, bus_call, loop);</div><div><span class="" style="white-space:pre"> </span>gst_object_unref (bus);</div><div> </div><div> /* Set the pipeline to "playing" state*/</div><div><span class="" style="white-space:pre"> </span>gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div><br></div><div><span class="" style="white-space:pre"> </span>/* Iterate */</div><div><span class="" style="white-space:pre"> </span>g_print ("Running...\n");</div><div><br></div><div><span class="" style="white-space:pre"> </span>//g_timeout_add_seconds (1, timeout_cb, loop);</div><div><br></div><div><span class="" style="white-space:pre"> </span>g_main_loop_run (loop);<span class="" style="white-space:pre"> </span></div><div><br></div><div><span class="" style="white-space:pre"> </span>/* Out of the main loop, clean up nicely */</div><div><span class="" style="white-space:pre"> </span>g_print ("Returned, stopping playback\n");</div><div><span class="" style="white-space:pre"> </span>gst_element_set_state (pipeline, GST_STATE_NULL);</div><div><br></div><div><span class="" style="white-space:pre"> </span>g_print ("Deleting pipeline\n");</div><div><span class="" style="white-space:pre"> </span>gst_object_unref (GST_OBJECT (pipeline));</div><div><br></div><div><span class="" style="white-space:pre"> </span>return 0;</div><div>}</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 May 2016 at 02:33, Sebastian Dröge <span dir="ltr"><<a href="mailto:sebastian@centricular.com" target="_blank">sebastian@centricular.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mi, 2016-05-11 at 02:24 -0400, Michael Guinzbourg wrote:<br>
> I think the issue is very easy to reproduce: build any pipeline which<br>
> has encodebin element and ask encodebin to encode in mpeg2. then play<br>
> any file and try to restart pipeline when it reaches the end of file.<br>
<br>
</span>Can you provide such code then? That makes it more likely someone tries<br>
to find the reason for your crash. Your code does not really provide a<br>
lot of details about what you're doing there.<br>
<br>
Also please provide a backtrace of all threads with gdb.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Sebastian Dröge, Centricular Ltd · <a href="http://www.centricular.com" rel="noreferrer" target="_blank">http://www.centricular.com</a><br>
<br>
</div></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br></div>