add custom tags to flac file.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

add custom tags to flac file.

Jacobo Luis Mejías Albertos
I try to registry some custom tags with 'gst_tag_register()' for using
it with flacenc, but when I do the merge the final output file only show
the predefined tags.

This is and excerpt of the code related with the problem:

GstElement* encoder = gst_element_factory_make("flacenc", "encoder");
...
for (auto& tag : mytags) // mytags are a std::multimap<const char*,
constchar*>
    gst_tag_register(tag.first, GST_TAG_FLAG_META, G_TYPE_STRING,
tag.first, tag.second, gst_tag_merge_strings_with_comma);
...
GstTagSetter* tagger = GST_TAG_SETTER(encoder);
if (tagger) {
   gst_tag_setter_set_tag_merge_mode(tagger, GST_TAG_MERGE_APPEND);
   GstTagList* list = gst_tag_list_new_empty();
   for (auto& tag : meta)
      gst_tag_list_add_values(list, GST_TAG_MERGE_APPEND, tag.first,
tag.second);
   gst_tag_setter_merge_tags(tagger, list, GST_TAG_MERGE_APPEND);
   gst_tag_list_unref(list);
}

gst_element_set_state(pipeline, GST_STATE_PLAYING);
...

I do something bad or flacenc don't support custom tags ?

--
Jacobo Luis Mejías Albertos
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: add custom tags to flac file.

Thiago Sousa Santos-2
 

On Sat, Aug 26, 2017 at 5:00 PM, Jacobo Luis Mejías Albertos <[hidden email]> wrote:
I try to registry some custom tags with 'gst_tag_register()' for using it with flacenc, but when I do the merge the final output file only show the predefined tags.

This is and excerpt of the code related with the problem:

GstElement* encoder = gst_element_factory_make("flacenc", "encoder");
...
for (auto& tag : mytags) // mytags are a std::multimap<const char*, constchar*>
   gst_tag_register(tag.first, GST_TAG_FLAG_META, G_TYPE_STRING, tag.first, tag.second, gst_tag_merge_strings_with_comma);
...
GstTagSetter* tagger = GST_TAG_SETTER(encoder);
if (tagger) {
  gst_tag_setter_set_tag_merge_mode(tagger, GST_TAG_MERGE_APPEND);
  GstTagList* list = gst_tag_list_new_empty();
  for (auto& tag : meta)
     gst_tag_list_add_values(list, GST_TAG_MERGE_APPEND, tag.first, tag.second);
  gst_tag_setter_merge_tags(tagger, list, GST_TAG_MERGE_APPEND);
  gst_tag_list_unref(list);
}

gst_element_set_state(pipeline, GST_STATE_PLAYING);
...

I do something bad or flacenc don't support custom tags ?

From a quick look at gstflacenc.c, check add_one_tag function. It will use the gst-plugins-base tag library to convert the tags to vorbis tags. The gstvorbistag.c in gst-plugins-base is where this is one, check gst_tag_to_vorbis_comments which uses gst_tag_to_vorbis_tag to match gstreamer tags to vorbis tags. The likely reason it is not working is because your custom tags are not part of the list it knows how to map.

You could also add your tags there, make it dynamically extensible and provide functions to register custom tags or make it handle (somehow) tags it doesn't know. Depends on your overall use case and how generic you want this solution to be.
 

--
Jacobo Luis Mejías Albertos
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



--
Thiago Sousa Santos

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: add custom tags to flac file.

Tim Müller
In reply to this post by Jacobo Luis Mejías Albertos
On Sun, 2017-08-27 at 01:00 +0100, Jacobo Luis Mejías Albertos wrote:

Hi,


> I do something bad or flacenc don't support custom tags ?

As Thiago already said, we can only write known tags, since we wouldn't
know how to map them otherwise.

For your use case, there's GST_TAG_EXTENDED_COMMENT, which is basically
a key=value string, and will be written as key=value in the
vorbiscomment in the flac header. So no need to register your own tags.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

Join us at the GStreamer Conference!
21-22 October 2017 in Prague, Czech Republic
http://gstreamer.freedesktop.org/conference/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel