[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read artwork bitmaps embedded in MP3 files as "image"-Tag


Le 10/03/2026 à 13:18, Claus Dietrich a écrit :
Am 10.03.26 um 02:44 schrieb Benoît Minisini:
I added in the last commit support for GStreamer "sample"
objects, through a new 'MediaSample' class.

The image tag returns such an object, that includes the image
contents (returned by the 'Data' property), and some metadata
(returned by the 'Info' property).

That metadata is returned as a collection of collections. The
contents of these collections can be anything.

In the case of the mp3 I used for testing (not yours), I get that:

{"image/jpeg":{"width":400,"height":400,"sof-marker":2}}

It seems to mean that the image is a JPEG, so you have to use the 'Image.FromString()' method to transform the sample data into an
Image object.

Try it and tell me if you have any problem.

Hi Benoît!

Thanks a lot for your attention in this matter.

It works for the image tag, but it doesn't allow to access the
TagList- Data any longer. The TagList-Collection now always returns
an object instead of a string. So my demo app is now crashing at

TextArea1.text &= TagList[sTag]

These tag Strings are certainly used in most Gambas media
applications out there.

This is what I did:

Public Sub PipeEvents_Tag(TagList As MediaTagList)

For Each sTag As String In Taglist.Tags If sTag = "image" Then Print
"Info: "; TagList[sTag].Info Print "Type: ";
TypeOf(TagList[sTag].Info) Print "Size: "; TagList[sTag].Size PictureBox1.Image = Image.FromString(TagList[sTag].Data) else 'TextArea1.text &= TagList[sTag] '<--- OUT-COMMENTED BECAUSE THE
APP IS NOW CRASHING HERE Endif Next

End

I hope you have an idea to get this backwards compatible with
existing code out there (in best case). If not (which would be OK
for me) ... how about new Text Property in the MediaSample class?
Deliver any text via the Data Property of the new MediaSample-Class?


It's backward compatible: it was never said that a tag is only a string.
A tag can be any datatype.

I can eventually make an automatic conversion of MediaSample to string,
but what for?

In case of an image tag, the Info-property in my case returns "(Collection 0x58fd8b0c2918)" and a test showed that this data type
is 16. So it seems that we have a new data type in Gambas -
correct?

Of course not. TypeOf() returns 'gb.Object' (= 16) to tells you that the
value contains an object.

The documentation of TypeOf(): https://gambaswiki.org/wiki/lang/typeof

I would have expected a String under the title "Info". As the info- property is supposed to be a collection of collections - how could
this object be enumerated - and would there be any use by doing
this? I am further wondering why (and how) you got "{"image/jpeg": {"width":400,"height":400,"sof-marker":2}}" in your project.

It's the JSON corresponding to the collection. How do you want me to
print the contents of a collection inside a mail otherwise?

You enumerate the contents of the Info property as you like. I can just
guarantee that it is a collection of collections. The contents inside
the child collections can be anything.

There is no way to know what exactly is inside the Data property of a
MediaSample. Apparently the key of the first collection seems to be a
mimetype, but I think it's purely a convention of the GStreamer plugin
that decodes the MP3. Another plugin may use a totally different way of
communicating the contents of the metadata associated with the decoded file.

Good luck with that!

--
Benoît Minisini.


Follow-Ups:
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
References:
How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>