[gst-devel] Help needed to diagnose critical error message while setting tags on flac stream

Tim-Philipp Müller t.i.m at zen.co.uk
Thu Apr 15 00:38:36 CEST 2010

On Wed, 2010-04-14 at 13:55 +0530, Yogesh Marwaha wrote:

> I'm trying to write tags to a flac file. Here is the relevant code: -
>  (snip)
> When the program is run, following messages are shown (even though the
> result 
> looks fine i.e. tags looks to be properly added to the file): -
> ** (<unknown>:5137): CRITICAL **: gst_adapter_take_buffer: assertion `nbytes > 
> 0' failed
> (<unknown>:5137): GStreamer-CRITICAL **: gst_buffer_set_caps: assertion 
> `buffer != NULL' failed
> (<unknown>:5137): GStreamer-CRITICAL **: gst_pad_push: assertion 
> `GST_IS_BUFFER (buffer)' failed
> Any idea where my code is going wrong?

It's not your code that's wrong, it's a bug in the flactag element, as this pipeline shows:

  gst-launch-0.10 audiotestsrc ! flacenc ! flactag ! fakesink

I've filed a bug in bugzilla about this:

A few comments on your code:

>     //pipeline
>     GstElement *pipeline = gst_pipeline_new("flac-encoder");
>     //encoder
>     GstElement *encoder = gst_element_factory_make("flacenc", "flac-encoder-
> element");
>     g_object_set(G_OBJECT(encoder), "quality", mCompressionQuality, NULL);
>     //tagger
>     GstElement *tagger = gst_element_factory_make("flactag", "flac-encoder-
> tag-element");
>     GstTagSetter *tagSetter = GST_TAG_SETTER(tagger);

There's no need for the flactag element in this context. The flacenc
encoder element implements the GstTagSetter interface as well, so you
should just use that directly on flacenc. The flactag element was
written to re-tag an existing stream without re-encoding (it should work
fine of course, it just seems that no one has ever tested it after

>     GValue value = {0};
>     g_value_init(&value, G_TYPE_STRING);
>     g_value_set_static_string(&value, "Hello");
>     gst_tag_setter_add_tag_value(tagSetter, GST_TAG_MERGE_REPLACE, "title", 
> &value);
>     g_value_unset(&value);
>     g_value_init(&value, G_TYPE_STRING);
>     g_value_set_static_string(&value, "Monty");
>     gst_tag_setter_add_tag_value(tagSetter, GST_TAG_MERGE_REPLACE, "composer", 
> &value);

You could replace all that with:

  gst_tag_setter_add_tags (tagSetter, GST_TAG_MERGE_REPLACE,
      GST_TAG_TITLE, "Hello",
      GST_TAG_COMPOSER, "Monty",

>     gchar *location = g_strdup(file.toLocal8Bit());
>     //link and finalize
>     g_object_set(G_OBJECT(sink), "location", location, NULL);

You might be leaking the location string here if you don't do a g_free()
somewhere else.


More information about the gstreamer-devel mailing list