mp4 command line tagger |
![]() ![]() |
mp4 command line tagger |
Aug 9 2003, 11:53
Post
#1
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
A test version of my mp4 command line tagger is available at:
Source: http://users.rcn.com/rpritz/tgsrc809.zip Windows exe: http://users.rcn.com/rpritz/tg809.zip This is still in development. Use at your own risk. Any comments welcome. |
|
|
|
Aug 9 2003, 21:49
Post
#2
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
Good work!
Now it remains to do the tagging just after the encoding through QuickTime by modifying the VBS script for EAC. Adding of course the right parameters to pass by EAC like name, title, track, etc... Encoding and tagging in one pass, who'll need Nero, Sveta or Foobar... Oooopsssss, don't hit me! I'm joking! |
|
|
|
Aug 10 2003, 12:08
Post
#3
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
I modified the script for EAC & QuickTime.
Now I can do encoding and tagging in one pass, but there is apparently a problem with your program. I cannot tag the year, be it by the script of manually. :'( But at least that doesn't pertub the tagging process |
|
|
|
Aug 10 2003, 12:56
Post
#4
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
Try this version:
http://users.rcn.com/rpritz/tg810.zip http://users.rcn.com/rpritz/tgsrc810.zip By the way, did you ever find a way to feed keystrokes to QT even if QT loses the focus? |
|
|
|
Aug 10 2003, 15:45
Post
#5
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
Thanks!
Now it works fine (but EphPod doesn't) A singer labeled "Pop" was converted to "Jazz" by EphPod. The tagged songs transferred on my Mac renamed to .m4a were imported perfectly in iTunes. As for the losing of focus, well I added some AppActivate to the script to help. So where should I put the new script, here or the old forum in which it evolved? |
|
|
|
Aug 10 2003, 17:49
Post
#6
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
>A singer labeled "Pop" was converted to "Jazz" by EphPod
Just to be clear, iTunes reads correctly? foobar also reads what seems to be correctly. I've had the same problem with EphPod. Which version of EphPod are you using? I'd like to be able to tell the author he's inconsistent with iTunes. >So where should I put the new script, here or the old forum in which it evolved? Either way. There should be a way to send keys using windows api rather than vbs 'sendkeys', but I don't know how. This post has been edited by richard123: Aug 10 2003, 17:59 |
|
|
|
Aug 10 2003, 18:50
Post
#7
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
>Which version of EphPod are you using? I'd like to be able to
>tell the author he's inconsistent with iTunes. The download link I got said 2.71, but when I launch EphPod is say 2.70b. Maybe he's not inconsistent, he simply doesn't put the tag as it is written originally? And yes iTunes gets it right. >Either way. There should be a way to send keys using >windows api rather than vbs 'sendkeys', but I don't know how. Me neither. Anyway here is the new script. Following the configuration procedure of EAC as described here : http://www.hydrogenaudio.org/forums/index....showtopic=10874 This option "Additional command line options" was set to C:\SAVE\EAC.vbs %s %d Now it MUST be set like this C:\SAVE\EAC.vbs %s %d "%a" "%g" "%t" %n "%m" %y Note : The quotes are important to encompass names with spaces Also, the EAC.vbs script and the TG.exe program are in the C:\SAVE directory, so modify to your liking to accomodate your needs. This post has been edited by FrDakota: Aug 10 2003, 18:58 |
|
|
|
Aug 10 2003, 18:59
Post
#8
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
CODE Function CallQuickTime(Path)
Dim fso, mp4, mp5, c, Car, QT, Str Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") Str = "" For c = 1 To Len(Path) 'Convert 1 \ in 2 \ If Mid(Path, c, 1) = "\" Then Str = Str & "\\" Else Str = Str & Mid(Path, c, 1) End If Next mp4 = Left(Path, Len(Path)-3) & "mp4" ' get filename.wav by Zeer For c = 1 To Len(Path) If Mid(Path, c, 1) = "\" Then wavx=c Else End If Next wav=Right(Path,Len(Path)-wavx) wav=Left(wav,Len(Path)-3) Path = Chr(34) & Str & Chr(34) QT = Chr(34) & "C:\\Program Files\\QuickTime\\QuickTimePlayer.exe " & Chr (34) WshShell.Run(QT & Path) WScript.Sleep 3000 Do 'Loop until the mp4 file really exists WshShell.AppActivate(wav) WScript.Sleep 1500 WshShell.SendKeys "%FE" 'File Export, could be "^E" WScript.Sleep 500 WshShell.SendKeys ("C:\Temp.mp4") 'Temporary mp4 filename WScript.Sleep 500 WshShell.SendKeys "{ENTER}" WScript.Sleep 8000 'Check to see if the temp file is still here While fso.FileExists ("C:\Temp.mp5") WScript.Sleep 2000 'With CScript.exe instead of WScript.exe I could put 500 'IMPORTANT : Increase the value under slower systems (.wav already exists bug) Wend 'The Enter was added in case QuickTime says .wav file already exists, to clear the error. 'It launches playing if all goes well. WScript.Sleep 500 WshShell.AppActivate(wav) WshShell.SendKeys "{ENTER}" WScript.Sleep 500 WshShell.SendKeys "{ESC}" WScript.Sleep 500 Loop Until fso.FileExists("C:\Temp.mp4") 'Close QuickTime WshShell.AppActivate(wav) WScript.Sleep 500 WshShell.SendKeys "{ESC}" WScript.Sleep 500 WshShell.SendKeys "%FX" WScript.Sleep 2000 'A little wait to let QuickTime exit before returning to EAC ' If not EAC could not be able to rename the wav file to original, then delete it. 'IMPORTANT : Increase the value under slower systems (files do not regain their original names bug) 'Added part here for tagging the mp4. Tagger = Chr(34) & "C:\\SAVE\\tg.exe " & Chr (34) TagParams = "C:\Temp.mp4" & " --artist " & Artist & " --album " & Album & " --title " & Title & " --track " & Track & " --genre " & Genre & " --year " & CDYear WshShell.Run(Tagger & TagParams) 'Wait some seconds for tagging to occur. WScript.Sleep 3000 'Move the Temp.mp4 to the right place while renaming it fso.MoveFile "C:\Temp.mp4" , mp4 Set fso = Nothing End Function 'Get the 8 first arguments and assumes they are %s %d "%a" "%g" "%t" %n "%m" %y '(source, destination, Artist, Album, Title, Track number, Genre, Year In EAC) Dim wav Set objArgs = WScript.Arguments wav = objArgs(0) mp4 = objArgs(1) Artist = Chr(34) & objArgs(2) & Chr(34) Album = Chr(34) & objArgs(3) & Chr(34) Title = Chr(34) & objArgs(4) & Chr(34) Track = objArgs(5) Genre = Chr(34) & objArgs(6) & Chr(34) CDYear = objArgs(7) CallQuickTime(wav) Wscript.Quit This post has been edited by FrDakota: Aug 14 2003, 08:36 |
|
|
|
Aug 10 2003, 20:14
Post
#9
|
|
|
Group: Members Posts: 208 Joined: 28-May 02 From: Helsingborg Member No.: 2147 |
Don't you know that there is a bug with long post on this board ?
seems like it worked this time though, just letting you know .... |
|
|
|
Aug 10 2003, 20:47
Post
#10
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
QUOTE (treech @ Aug 10 2003, 11:14 AM) Don't you know that there is a bug with long post on this board ? seems like it worked this time though, just letting you know .... Yeah! I noticed That's why I splitted on two posts, the code was all fouled up. The ruse worked (w00t) |
|
|
|
Aug 10 2003, 23:51
Post
#11
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
EhpPod & tags
>Maybe he's not inconsistent, he simply doesn't put the tag as it is written It's not clear what he's doing. He says he prefers id3v2 string genre tags to id3v1 numeric genre tags. But if EphPod is not reading the tags created by iTunes, then he's doing something wrong. As far as I can tell from files people have sent to me, iTunes creates numeric rather string genre tags. Could you look at a few iTunes created mp4's and confirm that iTunes is creating numeric genre tags? Given that you're saying he's not reading iTunes tags, it appears he's doing something wrong. |
|
|
|
Aug 11 2003, 08:47
Post
#12
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
You were right.
I Hex Edited some iTunes created .m4a and the "gnre" tag is numeric I wrongly thought it was alpha. But the year is alpha. $0E for Pop. $1D for Vocal if that helps. iTunes is using CDDB, I don't know if it differs from freedb but that seems not to be the problem. Or maybe you and him don't use the same genre tables? Edit: I found a table for genre here : http://www.id3.org/id3v2-00.txt Apparently the tags are the same except the iTunes tags are plus 1. iTunes -> ID Tags $0E -> $0D = Pop $1D -> $1C = Vocal So you see he read the tags correctly but since they are out of sync the result is wrong. Maybe he sould add a preference in EphPod for people wanting to use iTunes rules or ID3 rules, or simply go for iTunes rules for mp4. End edit: Meanwhile I correct the tags manually in EphPod after transfer. This post has been edited by FrDakota: Aug 11 2003, 09:37 |
|
|
|
Aug 14 2003, 08:38
Post
#13
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
I've just edited the Script Code message.
In fact it was wrong and I haven't noticed it till now. |
|
|
|
Aug 14 2003, 20:55
Post
#14
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
EphPod should really read iTunes tags. iTunes and every other mp4 tag writer or reader I know of uses id3v1 + 1.
I could add a parameter to do id3v1 (or any other tagging scheme EphPod uses), if I had the patience to figure out exactly what EphPod is doing. |
|
|
|
Aug 14 2003, 21:14
Post
#15
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
It's not to you to adapt to the wrong doing of EphPod.
If you allowed a tagging "out of sync" with iTunes you wouldn't be able to trust any mp4 file you could encounter. iTunes is quite a reference for mp4 tagging, EphPod must follow it's steps, we're not talking about mp3's. |
|
|
|
Aug 17 2003, 09:24
Post
#16
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
Yesterday I encoded and tagged some tracks which contain accented caracters, it became a great problem.
Your tagging Richard isn't accepted by EphPod (I don't know why it crashes Strangely EphPod refused also one music in the rip which hadn't any accented caracter in it??? (other freshly encoded CDs imported perfectly also) For iTunes, if you try to import songs tagged by TG.EXE with accented caracters in them the name becames truncaded at the first special char. "Générique" became "G". In fact iTunes uses a marker to identify accented chars. It's "$C3" é = C3,A9 è = C3,A8 ê = C3,AA Well you need to do a correlating table if you want to tag in the iTunes way. :'( It was all working so well... I re encoded the same tracks without tagging and this time EphPod accepted them |
|
|
|
Aug 17 2003, 22:29
Post
#17
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
Alas, I never use accented characters and therefore never test with them. I'll poke around a bit and see if there are any easy fixes.
Does --remove clear the bad tags? |
|
|
|
Aug 18 2003, 01:27
Post
#18
|
|
![]() Group: Members Posts: 487 Joined: 6-April 03 From: Århus, Denmark Member No.: 5861 |
I believe iTunes uses UTF-8 for the tags. Your OS should be able to aid you in converting it to something else.
|
|
|
|
Aug 18 2003, 08:43
Post
#19
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
I haven't tried the --remove tag Richard, but I'll do a check.
Danchr, you sent me in the right direction, it is UTF-8 as I could find here : http://www1.tip.nl/~t876506/utf8tbl.html Some UTF-8 explanation : http://www.joconner.com/javai18n/articles/UTF8.html So in fact there would have to be a table that will convert from Unicode to UTF-8 as far as I understood. Maybe you have UTF tools available in your developing environment Richard? Meanwhile, it seems the characters above $80 must be replaced by a standard char if you want iTunes to be able to read the tags and not lose what's after the special char. i.e : Say there is "Générique" changed to "G_n_rique" at least iTunes will read this. Well you won't be alone in that task, EphPod too must be modified to understand UTF-8 Good luck. |
|
|
|
Aug 18 2003, 09:58
Post
#20
|
|
![]() Group: Members Posts: 487 Joined: 6-April 03 From: Århus, Denmark Member No.: 5861 |
QUOTE (FrDakota @ Aug 18 2003, 08:43 AM) So in fact there would have to be a table that will convert from Unicode to UTF-8 as far as I understood. Maybe you have UTF tools available in your developing environment Richard? You should consider scouring the Windows SDK for information on UTF-8. I find it very hard to believe that there isn't a routine for converting to and from UTF-8. UTF-8 is an 8 bit representation of all Unicode characters, btw. |
|
|
|
Aug 18 2003, 12:58
Post
#21
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
I'm using a windows port of gcc, so I should have standard libraries, etc.
It should be trivial to change any char above 0x7f to a space, but there must be a routine which will map anything above 0x7f to something more sensible. Although there may be a number of different char sets, which would complicate the problem. Will EphPod transfer a song tagged by iTunes with accented chars? The database on the ipod (iTunesDB) uses 2 bytes to store each char. This seems different than the way tags are stored within a song. How is iTunes storing the accented chars in a song? Please post a sample hex sequence or two of the tag as stored by iTunes. Here's some more info: http://www.cl.cam.ac.uk/~mgk25/unicode.html (I did not read the whole thing). This post has been edited by richard123: Aug 18 2003, 13:20 |
|
|
|
Aug 18 2003, 17:51
Post
#22
|
|
![]() Group: Members Posts: 128 Joined: 14-June 03 Member No.: 7174 |
Yes coding in iTunesDB and in a song are different.
iTunesDB is in Unicode 16 bits or UCS (Universal Character Set) and you can verify the coding with the accessory Chartable provided with Windows. U+xxxx for the caracter code. Coding in a song is done in UTF-8 apparently. and EphPod doesn't know how to handle it. (But song encoded with iTunes seems not to make it crash) I have an artist : Déanta In iTunes m4a it gives (I space them to explain) D | Ã | © | a | n | t | a - Shown like that (without the bars) in EphPod Hex 44|C3|A9|61|6E|74|61 If you look at the UTF-8 code of C3;A9 it's "é". I have a song titled : Générique G | Ã | © | n | Ã | © | r | i | q | u | e 47|C3|A9|6E|C3|A9|72|69|71|75|65 Look about the code ranges in UTF-8 on table B-2. http://www.csis.gvsu.edu/GeneralInfo/Oracl...a96529/appb.htm Here is some code in C you may understand it, I don't http://www-124.ibm.com/pipermail/jikes-dev...uly/003495.html Very interesting about Unicode and UTF-8 and others. http://czyborra.com/utf/ Happy coding. PS : Using the --remove option allowed a buggy mp4 to be imported by EphPod afterwards. Addendum : I found a Microsoft page about Unicode and UTF including Windows API : http://msdn.microsoft.com/library/en-us/in...nicode_6bqr.asp This post has been edited by FrDakota: Aug 18 2003, 19:01 |
|
|
|
Aug 19 2003, 13:17
Post
#23
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
Case's tag handles utf-8. I'm browsing the source code for inspiration.
Have you tried the new EphPod beta? http://www.builderadius.com/ephpod/ephpod272.zip |
|
|
|
Aug 19 2003, 16:13
Post
#24
|
|
![]() Group: Members Posts: 487 Joined: 6-April 03 From: Århus, Denmark Member No.: 5861 |
You should consider using libmp4v2 for reading the tags. It's a part of the mpeg4ip project, but I find that the easiest way to get it is as part of faad2 from the FAAC project. I successfully used it to add MP4 metadata support to the giFT file sharing daemon (the patch hasn't been applied yet). The API is remarkable simple
|
|
|
|
Aug 19 2003, 22:40
Post
#25
|
|
|
Group: Members Posts: 318 Joined: 9-January 03 Member No.: 4498 |
QUOTE (danchr @ Aug 19 2003, 10:13 AM) You should consider using libmp4v2 for reading the tags. It's a part of the mpeg4ip project, but I find that the easiest way to get it is as part of faad2 from the FAAC project. I successfully used it to add MP4 metadata support to the giFT file sharing daemon (the patch hasn't been applied yet). The API is remarkable simple I've browsed the lib and am not sure it does anything I'm not doing in terms of tagging. I seem to be missing something about using it though. Can you post a few lines of code showing how to, for example, read an album name and then write a song title. I'm clearly misunderstanding its syntax, as it crashes when I call MP4GetMetadataAlbum. EDIT: CODE #include <stdio.h>
#include <mp4.h> int main(int argc, char *argv[]) { char song[] = "song.mp4"; char **album; MP4FileHandle f; f = MP4Read(song); album = (char **)malloc(256); MP4GetMetadataAlbum(f, album); printf("album: %s\n", *album); // so far, so good - reports album name MP4SetMetadataAlbum(f, "new title"); // why doesn't this work? MP4Close(f); return 0; } This post has been edited by richard123: Aug 20 2003, 00:38 |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 9th February 2010 - 17:47 |