Converting Ogg’s COVERART tag

Marcus Habermehl bmh1980de at gmail.com
Mon Dec 16 05:02:53 PST 2013


Am 16.12.2013 11:30, schrieb Sebastian Dröge:
> On Mo, 2013-12-16 at 04:46 +0100, Marcus Habermehl wrote:
>> Sorry, for the late answer. I was very busy the last week.
>>
>> Am 07.12.2013 11:31, schrieb Sebastian Dröge:
>>> On Fr, 2013-12-06 at 15:37 +0100, Marcus Habermehl wrote:
>>>> Hi.
>>>>
>>>> I have some Ogg files with the deprecated COVERART tag that I would like
>>>> to convert to the METADATA_BLOCK_PICTURE tag.
>>>>
>>>> For this I have written a small Python script to automatically do this
>>>> with GStreamer.
>>>>
>>>> How I can read tags, modify and write back I have already found out.
>>>>
>>>> Unfortunately, the GST_TAG_IMAGE is not written as I expected. But I do
>>>> not know if this is due to my code, or due to the GIR bindings.
>>>>
>>>> I get the original tags from the bus with a first pipeline (urisrc !
>>>> oggdemux ! oggmux ! fakesink). With these tags I create a modified
>>>> GstTagList.
>>>>
>>>> The COVERART tag is here changed from GST_TAG_PREVIEW_IMAGE to
>>>> GST_TAG_IMAGE and for the value I create a new GstSample. (‘value’ is
>>>> the value of the original tag.)
>>>>
>>>> buffer = value.get_buffer()
>>>> mime_struct = value.get_caps().get_structure(0)
>>>> mime_type = mime_struct.get_name()
>>>>
>>>> structure = Gst.Structure.new_empty(mime_type)
>>>> structure.set_value("height", mime_struct.get_value("height"))
>>>> structure.set_value("image-type", GstTag.TagImageType.FRONT_COVER)
>>>> structure.set_value("width", mime_struct.get_value("width"))
>>>>
>>>> caps = Gst.Caps.new_empty()
>>>> caps.append_structure(structure)
>>>>
>>>> sample = Gst.Sample.new(value.get_buffer(), caps, value.get_segment(), None)
>>>>
>>>> The modified GstTagList is written with a second pipeline (urisrc
>>>> oggdemux ! vorbistag ! oggmux ! urisink) correctly. But in GST_TAG_IMAGE
>>>> the ‘image-type’ field is removed from the GstSample. At least it is
>>>> when I reading the written tags no longer present.
>>>
>>> The code is writing the image type, or at least tries to. Does it show
>>> up in other software that does not use GStreamer? Can you provide a file
>>> that was created this way?
>>
>> I have installed an application that doesn’t use GStreamer and it shows
>> the image type as expected.
>>
>> Here is an Ogg file that I have created this way:
>> http://ubuntuone.com/6LfawrpRf20KQHO4ZeGZTd
> 
> It correctly includes the image type in the GstSample here, it's a
> GST_TAG_IMAGE_TYPE_FRONT_COVER. How do you get the image type from the
> sample? The image type is supposed to be in the structure that you can
> get with gst_sample_get_info().

Ah, okay. I’ve tried to get the image type from the caps I get with
gst_sample_get_caps(). For me it was logically, because I set it via the
caps.

Tanks for your help.

Greetings
Marcus


More information about the gstreamer-devel mailing list