Author Topic: Get track length and write to TLEN ID3 tag  (Read 665 times)

thecomfychair

  • Newbie
  • *
  • Posts: 9
I would like all my audio files to have their length embedded into their ID3 tags. ID3 V2 has the TLEN field for this purpose, but it's often not populated by encoders.
Is it possible for MusicBee to take the calculated track length in milliseconds and write it to the TLEN tag?

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33595
You cant do that directly in MusicBee but you might be able to it with the Advanced Tag Tools plugin

thecomfychair

  • Newbie
  • *
  • Posts: 9
Advanced Tag Tools gets 90% of the way, except the time is in mm:ss instead of milliseconds.

Do you know if it's possible to add a function to process the value of a tag? That way I could convert it with some simple multiplication and addition.

For anyone wanting to know how I got this far:
1. Create a new custom tag for Length in the Tags(1) tab in Preferences, making sure it is of type "Length"
2. Install the Additional Tagging and Reporting Tools plugin
3. Right-click on the track you want to add the tag to, and go to Additional Tagging Tools > Copy Tag...
4. Set 'Copy tag Time to tag Length', and check that the New Tag Value in the preview window contains a time value
5. Click 'Proceed'

Mayibongwe

  • Hero Member
  • *****
  • Posts: 518
...the time is in mm:ss instead of milliseconds.
Do you know if it's possible to add a function to process the value of a tag?
$Mul($Add($Mul($Split(<Time>,:,1),60),$Split(<Time>,:,2)),1000)

Does that formula give you expected results? (when using it in a virtual tag)
Bit busy of late.
I cannot frequent the forum on a regular basis like I used to - but I will be responding whenever I get the time.

thecomfychair

  • Newbie
  • *
  • Posts: 9
Quote
$Mul($Add($Mul($Split(<Time>,:,1),60),$Split(<Time>,:,2)),1000)

This worked perfectly, thank you very much!

For anyone else who wants to recreate the entire process:
1. Create a new custom tag called 'Length' in the Tags(1) tab in Preferences, making sure it is of type "Length"
2. Create a new virtual tag called "Time ms" and add the above formula. In the Main Player 'Tracks' view, the results can be verified by adding a new column for the 'Time ms' tag. A track that is 6:15 long gives the value 375000, which is correct.
2. Install the Additional Tagging and Reporting Tools plugin
3. Select the track(s) you want to add the tag to. Right-click and go to Additional Tagging Tools > Copy Tag...
4. Set 'Copy tag Time ms to tag Length', and check that the New Tag Value in the preview window contains the track length in milliseconds.
5. Click 'Proceed'. The new Length tag is now written to the ID3 TLEN field.

You can verify that the process has worked by right-clicking a track, then going to Edit>Tag Inspector and finding the TLEN tag code.