Jump to content

ID3 UDF ID3v1 & ID3v2 MP3 Tags


joeyb1275
 Share

Recommended Posts

I wasn't aware that Extended Tags was a Mp3Tag thing ... are you sure? Isn't it part of the ID3 v2.x standard, and Mp3Tag is just utilizing that, just like any other program can do, and some others no doubt do?

Off the top of my head, I recall that your code already deals with the Extended Tag set, just not individual elements if I remember rightly???

I may have modified your code ... can't remember??

I'm able to detect if any Extended Tags are present anyway, and remove them holus bolus.

Okay, I think I see now what you mean by extended tags. It looks like in your modified code you were trying to do some things on the ID3v2 'TXXX' frames, which is the "User defined text information frame" as defined by the specification. It looks like I was not reading this frame correctly, so I would like to fix this. Do you know how to get MP3Tag to create these frames?

Link to comment
Share on other sites

I hate to admit I still use something from 2004 to edit my MP3 tags.

The author released the C++ source years ago saying you could do whatever you like with it:

http://www.mutschler.de/mp3ext/

It adds a formatted tooltip when hovering over MP3's, custom icons (which are kind of cool), and a tab for editing tags built into the "Properties" page. I always thought it would be a good candidate to port to Autoit, or that the source might contain something of use to anyone doing an MP3 project. I haven't messed with C++ in 20 years so am not very enthisiastic about diving in, but I do yearn for something with the simplicity of use that MP3ext offers, but updated for the latest ID3 standards and x64 operating systems.

Edit: Have there been any new specifications since 2004? I noticed those 2004 docs mention support of ID3V1 V2.2 and V2.3.

Edited by Spiff59
Link to comment
Share on other sites

Okay, I think I see now what you mean by extended tags. It looks like in your modified code you were trying to do some things on the ID3v2 'TXXX' frames, which is the "User defined text information frame" as defined by the specification. It looks like I was not reading this frame correctly, so I would like to fix this. Do you know how to get MP3Tag to create these frames?

That sounds right.

Unfortunately perhaps, I've never used MP3Tag to do that ... I primarily use it as a checking program and to remove Ape Tags or fix corrupted tags.

@Spiff59 - ID3v2.4 is the current spec. I personally use the open source AudioShell to achieve much of what you explain mp3ext does, though there again, I only use it as checking mechanism or to fix Album Art issues with OGG files, etc. My own program gives a lot more automation options than either MP3Tag, Tagscanner or AudioShell, etc offer.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • 2 weeks later...

Good to hear from you again joeyb1275 ... thought we'd lost you.

Most of what I've done is just stop-gap quick fixes, but it may be a good place for you to start, so here it is.

ID3.au3

I think I've commented all the changes - just look for TheSaint to find them.

Looking forward to your improvements.

I'd also like to find some code that would indicate when Ape tags were present, plus allow removal of them only.

Finally!! I posted my first stab at the next version of the ID3 UDF. Thanks for your help! Let me know if you get to testing it.
Link to comment
Share on other sites

Finally!! I posted my first stab at the next version of the ID3 UDF. Thanks for your help! Let me know if you get to testing it.

Thanks!

I will.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I just added some fixes that may be important. There is a new version of the UDF, see first post for the changes.

No worries, will do, thanks again!

Have been so busy lately anyway, that I haven't had a chance to play with mp3's and what you've done, which includes any programming, etc.

Chief of which, was my oldest son moving back home, after leaving the Army, after getting back from his tour of Afghanistan, and then breaking up with his girlfriend, etc.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I just tested this on my system, Windows 7 x64, admin account, MP3 with 2.3 info and 1.1 info. I am unable to change the 1.1 version information, it says it wrote it (Using the demo ID3_Example_GUI_v3.1.au3 for this), but if I reopen the file the information hasn't changed. Also any information on the 1D3v2 More tab can't be changed, no matter what I change doesn't get written. I have even tried it with #RequireAdmin in the script, no difference, the only tag information I'm able to write is the information in the ID3v2.3.0 section. Am I doing something wrong?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@BrewManNH - I've not yet had time to adapt my program for this new UDF, but in the past, I've had issues where original ID3 tags were v2.4 &/or APE tags, and so gave grief when trying to update. I've been using MP3Tag to check for both ... removing APE tags and down-saving to ID3v2.3 ... so I could then use my program to do anything else I had in mind (add/edit/etc).

So if that's your issue too, then I believe this new UDF caters for checking & removing APE tags and working with (updating or removing) ID3v2.4.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I'll have to check to see what version tags are on the files I've been using it on.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I just tested this on my system, Windows 7 x64, admin account, MP3 with 2.3 info and 1.1 info. I am unable to change the 1.1 version information, it says it wrote it (Using the demo ID3_Example_GUI_v3.1.au3 for this), but if I reopen the file the information hasn't changed. Also any information on the 1D3v2 More tab can't be changed, no matter what I change doesn't get written. I have even tried it with #RequireAdmin in the script, no difference, the only tag information I'm able to write is the information in the ID3v2.3.0 section. Am I doing something wrong?

If you are using ID3_Example_GUI_v3.1.au3 to write ID3v2 tags just double check the _ID3v2_SaveTag_button_Pressed() function and make sure there is a _ID3v2Frame_SetFields() function for each field you want to set to the tag. This function did not cover all the input boxes in the GUI, I was still doing some testing in this part.

I am curious about the ID3v1.1 tags those should have been getting set when you press the $ID3v1_SaveTag_button that is located in the $hID3v1Group group control towards the bottom of the GUI. Can you try just changing the ID3v1 Artist Tag and press the ID3v1 save button and let me know if it does not change when you re-open the file?

Link to comment
Share on other sites

I just tested this on my system, Windows 7 x64, admin account, MP3 with 2.3 info and 1.1 info. I am unable to change the 1.1 version information, it says it wrote it (Using the demo ID3_Example_GUI_v3.1.au3 for this), but if I reopen the file the information hasn't changed. Also any information on the 1D3v2 More tab can't be changed, no matter what I change doesn't get written. I have even tried it with #RequireAdmin in the script, no difference, the only tag information I'm able to write is the information in the ID3v2.3.0 section. Am I doing something wrong?

I double checked the _ID3v1Tag_WriteToFile() and I found an error when saving new tag data. This should be fixed in v3.2. Thanks for the feedback! Let me know if you have any other problems.

Link to comment
Share on other sites

  • 2 weeks later...

I have updated the ID3 UDF to v3.3, see first post for latest changes. This update includes only a few small changes to ID3.au3, but a number of changes to ID3_Example_GUI.au3 have been made.

Let me know if there are any problems.

Link to comment
Share on other sites

How would I go about using this to write an ID3v2 tag to a file without having to write every field? I have tried changing just a couple of fields, and it seems to be changing those fields, but it's blanking out all the ones that I didn't set. This is using my own program to read and write the tags.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

How would I go about using this to write an ID3v2 tag to a file without having to write every field? I have tried changing just a couple of fields, and it seems to be changing those fields, but it's blanking out all the ones that I didn't set. This is using my own program to read and write the tags.

If you are using _ID3SetTagField("TIT2", $sFieldValue), then if $sFieldValue="" (an empty string such that StringLen($sFieldValue)=0) then the frame TIT2 should be removed from the ID3v2 tag. That being said, it seems like you are experiencing something I have not seen yet. If you could post some code that may help.

$Filename = FileOpenDialog( "Select Mp3 File", "", "Muisc (*.mp3)")
$sTagInfo = _ID3ReadTag($Filename)
_ID3SetTagField("COMM","TEST COMMENT - ID3v2 Comment Tag")
_ID3WriteTag($Filename)

In this example the ID3v2 tag in the file could also have a TXXX frame or any other frame that should not get changed by this code. The other frames should get written back to the file as they were read from the file.

Not sure if this helps, if you could show some code that will help me understand your problem more.

Link to comment
Share on other sites

I think I see my problem, I didn't realize you had to read all the tags in first before you can set/change the fields before writing them back to the file which I wasn't doing.

EDIT: I think the following line has an error, I think that $FrameData should be $bFrameData because all the variables around it are $bFrameData. This is at line 2833 in the function _h_ID3v2_EncodeStringToBinary.

$FrameData = StringToBinary($sFrameText,3) ;UTF16 Big Endian
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I think I see my problem, I didn't realize you had to read all the tags in first before you can set/change the fields before writing them back to the file which I wasn't doing.

EDIT: I think the following line has an error, I think that $FrameData should be $bFrameData because all the variables around it are $bFrameData. This is at line 2833 in the function _h_ID3v2_EncodeStringToBinary.

$FrameData = StringToBinary($sFrameText,3) ;UTF16 Big Endian

Actually, you should only have to read in all the ID3v2 tags if that's all you are going to change then write only the ID3v2 tag back, so the code could look like

$Filename = FileOpenDialog( "Select Mp3 File", "", "Muisc (*.mp3)")
$sTagInfo = _ID3ReadTag($Filename,2)
_ID3SetTagField("COMM","TEST COMMENT - ID3v2 Comment Tag")
_ID3WriteTag($Filename,2)

$FrameData = StringToBinary($sFrameText,3) ;UTF16 Big Endian

Yeah that is definitely a mistake, it should be $bFrameData. Thanks!

Edited by joeyb1275
Link to comment
Share on other sites

You've worked it out, but I guess the easiest way to think about it, is to see ID3 tags as just one long (header type) string, that only really become fields during the read/write process. So in a sense, you are replacing a string of fields with a string of fields, not just a field with a field.

I guess joeyb1275 could have made read an imperative before each write, which would be fine for single tag elements, but a lot of unnecessary repetition etc for multiple tags. Far better to read the whole string in once from file, modify the field/s within (in memory) then write/update the whole modified string once to file.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

You've worked it out, but I guess the easiest way to think about it, is to see ID3 tags as just one long (header type) string, that only really become fields during the read/write process. So in a sense, you are replacing a string of fields with a string of fields, not just a field with a field.

I guess joeyb1275 could have made read an imperative before each write, which would be fine for single tag elements, but a lot of unnecessary repetition etc for multiple tags. Far better to read the whole string in once from file, modify the field/s within (in memory) then write/update the whole modified string once to file.

TheSaint is correct. One major goal I had for version 3 was to speed up the reading/writing of tags and I found that reading/writing to the file separately for each frame was slower then reading/writing to memory. There are many ways to crack a nut, so if you have function suggestions I would be happy to try to incorporate them into future versions of ID3.au3.

I have also released a new version v3.4, with small changes. I have included a new au3 file to show some simple examples, ID3_SimpleExamples.au3. Let me know if there are more examples that would help and I can add them.

If the rapid updates are getting annoying, fear not, I will not likely be updating much more. I have my first child on the way and I don't think I will have much time in the near term for large updates. That being said if there is a major problem with a function I would still be able to make fixes and release as 3.4.X versions.

Thanks for all the testing and input!

Link to comment
Share on other sites

Once again, thanks, and all the best with your first child.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...