HydrogenAudio

Lossy Audio Compression => AAC => AAC - General => Topic started by: richard123 on 2003-08-09 11:53:48

Title: mp4 command line tagger
Post by: richard123 on 2003-08-09 11:53:48
A test version of my mp4 command line tagger is available at:

Source:  http://users.rcn.com/rpritz/tgsrc809.zip (http://users.rcn.com/rpritz/tgsrc809.zip)
Windows exe: http://users.rcn.com/rpritz/tg809.zip (http://users.rcn.com/rpritz/tg809.zip)

This is still in development. Use at your own risk.  Any comments welcome.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-09 21:49:13
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! 
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-10 12:08:52
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
Title: mp4 command line tagger
Post by: richard123 on 2003-08-10 12:56:35
Try this version:

http://users.rcn.com/rpritz/tg810.zip (http://users.rcn.com/rpritz/tg810.zip)
http://users.rcn.com/rpritz/tgsrc810.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?
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-10 15:45:16
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?
Title: mp4 command line tagger
Post by: richard123 on 2003-08-10 17:49:12
>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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-10 18:50:59
>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 (http://www.hydrogenaudio.org/forums/index.php?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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-10 18:59:52
Code: [Select]
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
Title: mp4 command line tagger
Post by: treech on 2003-08-10 20:14:28
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 .... 
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-10 20:47:47
Quote
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)
Title: mp4 command line tagger
Post by: richard123 on 2003-08-10 23:51:17
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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-11 08:47:48
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 (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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-14 08:38:43
I've just edited the Script Code message.

In fact it was wrong and I haven't noticed it till now.
Title: mp4 command line tagger
Post by: richard123 on 2003-08-14 20:55:13
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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-14 21:14:29
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.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-17 09:24:04
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  ) and by iTunes when it comes to accented caracters.

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".    (G for Gasp, Gulp?)

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 
Title: mp4 command line tagger
Post by: richard123 on 2003-08-17 22:29:55
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?
Title: mp4 command line tagger
Post by: danchr on 2003-08-18 01:27:50
I believe iTunes uses UTF-8 for the tags. Your OS should be able to aid you in converting it to something else.
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-18 08:43:54
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 (http://www1.tip.nl/~t876506/utf8tbl.html)

Some UTF-8 explanation : http://www.joconner.com/javai18n/articles/UTF8.html (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    (and so do the others)

Good luck.
Title: mp4 command line tagger
Post by: danchr on 2003-08-18 09:58:51
Quote
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.
Title: mp4 command line tagger
Post by: richard123 on 2003-08-18 12:58:37
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 (http://www.cl.cam.ac.uk/~mgk25/unicode.html) (I did not read the whole thing).
Title: mp4 command line tagger
Post by: FrDakota on 2003-08-18 17:51:29
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 (http://www.csis.gvsu.edu/GeneralInfo/Oracle/server.920/a96529/appb.htm)

Here is some code in C you may understand it, I don't  My C is very far....
http://www-124.ibm.com/pipermail/jikes-dev...uly/003495.html (http://www-124.ibm.com/pipermail/jikes-dev/2002-July/003495.html)

Very interesting about Unicode and UTF-8 and others.
http://czyborra.com/utf/ (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 (http://msdn.microsoft.com/library/en-us/intl/unicode_6bqr.asp)
Title: mp4 command line tagger
Post by: richard123 on 2003-08-19 13:17:37
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 (http://www.builderadius.com/ephpod/ephpod272.zip)
Title: mp4 command line tagger
Post by: danchr on 2003-08-19 16:13:45
You should consider using libmp4v2 for reading the tags. It's a part of the mpeg4ip (http://mpeg4ip.sourceforge.net/index.php) project, but I find that the easiest way to get it is as part of faad2 from the FAAC (http://sourceforge.net/projects/faac) project. I successfully used it to add MP4 metadata support to the giFT (http://www.giftproject.org) file sharing daemon (the patch hasn't been applied yet). The API is remarkable simple
Title: mp4 command line tagger
Post by: richard123 on 2003-08-19 22:40:24
Quote
You should consider using libmp4v2 for reading the tags. It's a part of the mpeg4ip (http://mpeg4ip.sourceforge.net/index.php) project, but I find that the easiest way to get it is as part of faad2 from the FAAC (http://sourceforge.net/projects/faac) project. I successfully used it to add MP4 metadata support to the giFT (http://www.giftproject.org) 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: [Select]
#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;
}
Title: mp4 command line tagger
Post by: danchr on 2003-08-20 09:50:14
Because you opened the file with read-only acess

s/f = MP4Read(song, 0);/f = MP4Modify(song, 0, 0);/

Anyway, if you using C or (ugh) C++, you should consider using libintl or libiconv for converting UTF-8 to <insert favourite encoding here>
Title: mp4 command line tagger
Post by: n68 on 2003-08-20 10:32:15
Quote
A test version of my mp4 command line tagger is available at:

Source:  http://users.rcn.com/rpritz/tgsrc809.zip (http://users.rcn.com/rpritz/tgsrc809.zip)
Windows exe: http://users.rcn.com/rpritz/tg809.zip (http://users.rcn.com/rpritz/tg809.zip)

This is still in development. Use at your own risk.  Any comments welcome.

Hey...


any chance of a gui/frontend...?

(  i know..)
Title: mp4 command line tagger
Post by: danchr on 2003-08-20 10:41:29
I tried to see if I could edit the album name, and I think I may have found a bug in libmp4v2. The code that didn't work is:

Code: [Select]
#include <stdio.h>

#include <mp4.h>

int main(int argc, char *argv[])
{
 char *album;
 MP4FileHandle f;

 if (argc < 3) {
   fprintf(stderr, "Usage: %s <song> <album>\n", argv[0]);
   return -1;
 }
    
 f = MP4Modify(argv[1], 0, 1);

 if (argc < 3) {
   fprintf(stderr, "Unable to open MP4 file %s\n", argv[1]);
   return -1;
 }

#if 1
 if (MP4GetMetadataAlbum(f, &album)) {
   printf("album: %s\n", album);
   free(album);
 }
#endif
 
 if (!MP4SetMetadataAlbum(f, argv[2]))
   printf("failed to set album\n", album);

#if 1
 if (MP4GetMetadataAlbum(f, &album)) {
   printf("album: %s\n", album);
   free(album);
 }
#endif

#if 1
 MP4Close(f);
#endif

 return 0;
}


With MP4Close() called, the file metadata can't be written to the file any more and mp4dump reports "MP4ERROR: ReadAtom: invalid atom size", but QuickTime can play the file. Without it, the metadata can be read and read, but the file can't be played.
Title: mp4 command line tagger
Post by: richard123 on 2003-08-20 12:34:36
Quote
Because you opened the file with read-only acess

s/f = MP4Read(song, 0);/f = MP4Modify(song, 0, 0);/

Is there any documentation for ths, other than the source code? 

Open("rb") is not likely to allow writing. Open("rb+") is much more likely.

Quote
f = MP4Modify(argv[1], 0, 1);

if (argc < 3) {
  fprintf(stderr, "Unable to open MP4 file %s\n", argv[1]);
  return -1;
}

That should be: if(f == 0), or something else.  It should not be argc < 3.

what are s/f and /f?
Title: mp4 command line tagger
Post by: richard123 on 2003-08-20 12:35:52
Quote
any chance of a gui/frontend...?

(  i know..)

Not from me :-)

Foobar's masstagger may be what you want
Title: mp4 command line tagger
Post by: menno on 2003-08-20 12:40:16
Quote
Is there any documentation for ths, other than the source code? 

There's very complete documentation in the mpeg4ip package:

/mpeg4ip/docs/mp4v2/

Menno
Title: mp4 command line tagger
Post by: richard123 on 2003-08-20 12:52:09
Quote
There's very complete documentation in the mpeg4ip package:

/mpeg4ip/docs/mp4v2/

Menno

I see documentation for Read and Modify, but none for the Metadata functions. 

Please either point me to the docs I'm not finding or post an example of modifying metadata.
Title: mp4 command line tagger
Post by: menno on 2003-08-20 12:56:44
Quote
Quote
There's very complete documentation in the mpeg4ip package:

/mpeg4ip/docs/mp4v2/

Menno

I see documentation for Read and Modify, but none for the Metadata functions. 

Please either point me to the docs I'm not finding or post an example of modifying metadata.

Ah yes, because I wrote those functions.

They work very easily. Just use the Get and Set functions inthe mp4meta.cpp file. One extra function is there to remove all metadata.

I noticed recently that with latest versions of the mp4v2 library it is not possible to read from a MP4 files when opened with MP4Modify(). So reading should only be done when the file is opened with MP4Read().

Menno
Title: mp4 command line tagger
Post by: richard123 on 2003-08-20 13:14:29
I noticed your name at the top of two of the meta source files. They're very nicely written, btw. 

>>I noticed recently that with latest versions of the mp4v2 library it is not possible to read from a MP4 files when opened with MP4Modify(). So reading should only be done when the file is opened with MP4Read().>>

That's why we should have docs for the get/set metadata functions beyond the source code  :-)

Also, I can't get Setmeta to work. Specifically, after running setmeta, the mp4 becomes unreadable with an invalid atom size error.  Please post a minimal program with a working example.
Title: mp4 command line tagger
Post by: menno on 2003-08-20 13:19:35
Quote
I noticed your name at the top of two of the meta source files. They're very nicely written, btw. 

>>I noticed recently that with latest versions of the mp4v2 library it is not possible to read from a MP4 files when opened with MP4Modify(). So reading should only be done when the file is opened with MP4Read().>>

That's why we should have docs for the get/set metadata functions beyond the source code  :-)

Also, I can't get Setmeta to work. Specifically, after running setmeta, the mp4 becomes unreadable with an invalid atom size error.  Please post a minimal program with a working example.

Both my foobar2000 plugin and winamp plugin contain working meta data code.

The writing/reading problem is a bug in the mp4 library, it happens with every  function, that reads something from the file, in the library.

Menno
Title: mp4 command line tagger
Post by: richard123 on 2003-08-20 13:23:25
Please post source code showing how to use setmeta. 

A program which opens with modify, sets, then closes fails.

edit: or are you saying the plugins are included in the faad source code?  I'll look
Title: mp4 command line tagger
Post by: danchr on 2003-08-20 14:12:17
Quote
Please post source code showing how to use setmeta.

I think I figured it out after looking at in_mp4.c: Run MP4MetadataDelete() before setting any metadata. This means that one should open the file, read the metadata, close it, open it, write it, and then close it. Rather complex, I'd say

Code: [Select]
#include <stdio.h>

#include <mp4.h>


int main(int argc, char *argv[])
{
 if (argc == 2) {
   MP4FileHandle f = MP4Read(argv[1], 0);
   char *album;

   if (!f) {
     fprintf(stderr, "Unable to open MP4 file %s\n", argv[1]);
     return -1;
   }

   if (MP4GetMetadataAlbum(f, &album)) {
     printf("album: %s\n", album);
     free(album);
   }

   if(!MP4Close(f))
     printf("failed to close MP4 file\n");

 } else if (argc == 3) {
   MP4FileHandle f = MP4Modify(argv[1], 0, 0);

   if (!f) {
     fprintf(stderr, "Unable to open MP4 file %s\n", argv[1]);
     return -1;
   }
   
   MP4MetadataDelete(f);
   
   if (!MP4SetMetadataAlbum(f, argv[2]))
     printf("failed to set album\n");
   
   if(!MP4Close(f))
     printf("failed to close MP4 file\n");

 } else {
   fprintf(stderr, "Usage: %s <song> [album]\n", argv[0]);
   return -1;
 }

 MP4Optimize(argv[1], NULL, 0);
 
 return 0;
}
Title: mp4 command line tagger
Post by: danchr on 2003-08-26 20:41:35
In case anyone is interested, I improved it a bit to make a useful MP4 tagger. It seems to work quite well  The C source code is hosted here (http://www.daimi.au.dk/~danchr/mac/mp4tag.c). It should work on Windows as well, but I haven't tried it there, only on Darwin and Linux.
Title: mp4 command line tagger
Post by: jefv on 2003-09-02 22:13:53
Okay, I'm kind of ignorant when it comes to C code. How would I compile this? I'm guessing I need to drop it in the mpeg4ip file structure, but where?

Thanks!
Title: mp4 command line tagger
Post by: MOCKBA on 2003-09-03 00:15:45
Sorry, I'm new for this forum and not familiar yet how to find something in archives. I need a good documentation and probably sources, to parse MP4 header for my iPod uploaded program. Since, it's Java, I can't use C sources directly. Actually, I need not too much, just extract time and some general attributes, as title, artist, album, year, track # and so on. Editing of MP4 tag will be next goal though. I have QuickTime atoms extractor ready, but still in searching of a good interpretation of them. Thanks for help.
Title: mp4 command line tagger
Post by: richard123 on 2003-09-03 20:49:02
Newer version of source is source (http://users.rcn.com/rpritz/tg03092003.zip)
Windows exe at exe (http://users.rcn.com/rpritz/tg0309exe.zip)
Title: mp4 command line tagger
Post by: richard123 on 2003-09-03 20:53:06
>>How would I compile this?

depends on which compiler and linker you have

>>I need a good documentation and probably sources, to parse MP4 header for my iPod uploaded program

my source code might be helpful.  so might menno's routine in the sources for faad2.
Title: mp4 command line tagger
Post by: FrDakota on 2003-09-04 09:36:27
Quote
Newer version of source is source (http://users.rcn.com/rpritz/tg03092003.zip)
Windows exe at exe (http://users.rcn.com/rpritz/tg0309exe.zip)

Well Richard, sorry to say that your new version is still of no use to me 

Since you don't use UTF-8, it remains incompatible with iTunes for all my songs with accented caracters in their title. :'(

What is the difference with your old versions ?

...

The life saving act " Format C: " 
Title: mp4 command line tagger
Post by: richard123 on 2003-09-04 12:29:24
I haven't had the energy to learn utf-8, sorry.

The new version takes out a lot of stuff that was required for a previous version of Ephpod and generally cleans up the code.
Title: mp4 command line tagger
Post by: richard123 on 2003-09-04 17:15:51
FrDakota,

I tried running the program with this command line
tg song.mp4 --artist Générique

It didn't crash or exhibit any odd behavior.  Similar result with using Générique on all other parmeters.  I'm not sure why you're having a problem.  Please provide more information.
Title: mp4 command line tagger
Post by: CyberInferno on 2003-09-05 10:52:21
Quote
Have you tried the new EphPod beta?   http://www.builderadius.com/ephpod/ephpod272.zip (http://www.builderadius.com/ephpod/ephpod272.zip)

How do you find out about the new EphPod betas?  IIRC, someone mentioned something about using a mailing list, but I can't find any information about it on the Ephod site.  Thanks!
Title: mp4 command line tagger
Post by: FrDakota on 2003-09-06 19:13:36
Quote
It didn't crash or exhibit any odd behavior.  Similar result with using Générique on all other parmeters.  I'm not sure why you're having a problem.  Please provide more information.

The crash I had was with EphPod (2.71b I think) not tg.exe.

I haven't tried more since there is no UTF-8 support.

I simply avoid tagging for now, simply because I don't want to have problems with iTunes when I pass mp4 from PC to Mac.

And since I don't move much the songs around my iPod that's not critical.

And I don't tag them on my Mac since it would mean, rip (with EAC) encode on the PC then transfer to iTunes and back to PC to transfer with EphPod. Not something I'm willing to do.

I would do it if I could reduce the speed of the CD-Rom while ripping. But I've nothing to do that on my Mac.

I must find an Apple CD-150 to do that, reads at 1x  that would take care of the Copy Control also since it's mono session
Title: mp4 command line tagger
Post by: darp on 2003-09-09 05:42:11
Why don't you add another parameter for the total tracks in the album? Right now your code sets this to be the same as the track number.
Title: mp4 command line tagger
Post by: richard123 on 2003-09-09 19:28:55
FrDakota:  what would you like the program to do with accented chars: change to _ or change to utf-8? will both iTunes and EphPod handle files tagged utf-8?

darp:  laziness is the answer, but I'll try to implement.  I'm also setting disk to 0 at the moment, which I'll also try to fix.
Title: mp4 command line tagger
Post by: danchr on 2003-09-09 21:29:37
Quote
Why don't you add another parameter for the total tracks in the album? Right now your code sets this to be the same as the track number.

I once hacked a small MPEG4IP-based tagger together. It supports (almost) all the common tags, but not freeform, though. It should be on RareWares along with the source code. If you make a statically compiled Windows binary, send it to me
Title: mp4 command line tagger
Post by: rjamorim on 2003-09-09 23:37:33
Quote
I once hacked a small MPEG4IP-based tagger together. It supports (almost) all the common tags, but not freeform, though. It should be on RareWares along with the source code. If you make a statically compiled Windows binary, send it to me

Here it is. Didn't get to announce it yet.

http://rarewares.hydrogenaudio.org/files/m...win.tar.bz2.tar (http://rarewares.hydrogenaudio.org/files/mp4tag-darwin.tar.bz2.tar)

It's a MacOS X binary + sources.

I would also welcome Win32 binaries...


Regards;

Roberto.
Title: mp4 command line tagger
Post by: richard123 on 2003-09-10 16:22:53
[oops]
Title: mp4 command line tagger
Post by: richard123 on 2003-09-10 16:39:27
Quote
Why don't you add another parameter for the total tracks in the album? Right now your code sets this to be the same as the track number.

http://users.rcn.com/rpritz/tg030910src.zip (http://users.rcn.com/rpritz/tg030910src.zip)

http://users.rcn.com/rpritz/tg030910exe.zip (http://users.rcn.com/rpritz/tg030910exe.zip)
Title: mp4 command line tagger
Post by: FrDakota on 2003-09-12 14:05:21
Quote
FrDakota:  what would you like the program to do with accented chars: change to _ or change to utf-8? will both iTunes and EphPod handle files tagged utf-8?

Using UTF-8 would be the good way for me since it would mean compatibility with iTunes on the Mac and also the coming iTunes for Windows.

The files tagged with TG.exe now are accepted with EphPod (2.73, no crash) and accented caracters are OK, but we're talking about Windows app talking to another Windows app so they use the same charset.

The effect on moving a TG tagged file to iTunes is devastating since any string is cut at the first accented char (Générique becomes G).

iTunes tagged files appear incorrectly in EphPod since it doesn't have UTF-8 support either. But it more readable than the other way. (1 accented char is replaced by 2 chars, the string is understandable and can be corrected easily).

Using a "_" as a replacement char is a possible solution if one wants better compatibility with iTunes, maybe as an optional switch.

But I think that would be a temporary solution, because IMO TG and EphPod should support UTF-8 mostly for the compatibility with the coming iTunes for Windows.
Title: mp4 command line tagger
Post by: richard123 on 2003-09-12 22:25:34
Please see if this works.  The only change was to try to add utf support, but I haven't tested much. 

http://users.rcn.com/rpritz/tgutf.zip (http://users.rcn.com/rpritz/tgutf.zip)
Title: mp4 command line tagger
Post by: FrDakota on 2003-09-13 15:48:50
Quote
Please see if this works.  The only change was to try to add utf support, but I haven't tested much. 

http://users.rcn.com/rpritz/tgutf.zip (http://users.rcn.com/rpritz/tgutf.zip)

It works great! (w00t)

I've encoded and tagged 2 CDs with lots of accented chars.

iTunes got them all properly. Great job.

Now remains Joe with EphPod, he should handle UTF-8 so that I don't have to rename after transfer. 
Title: mp4 command line tagger
Post by: richard123 on 2003-09-13 15:57:43
Excellent!

What is EphPod doing with the utf-8 tagged files?
Title: mp4 command line tagger
Post by: FrDakota on 2003-09-13 21:11:06
Quote
Excellent!

What is EphPod doing with the utf-8 tagged files?

Showing them exactly like this.

La fête de l'être suprême -> La fête de l'être suprême

La révolution française -> La révolution française

Générique -> Générique

Since EphPod doesn't interpret the string, so you see it's quite easy to replace 2 chars by 1 afterwards. Only annoying, but since I want compatibility with iTunes I can live with that.  (for the moment  )

Just in case I transfer from iPod to Mac/PC 
Title: mp4 command line tagger
Post by: siorin on 2003-11-09 00:11:53
I can't use tag.exe
I tried utf and 030910 version.But both of tag.exe make error with msvcrt.dll
msvcrt.dll ver 7.0.2600.1106 00033a96
Title: mp4 command line tagger
Post by: Chastity on 2003-11-15 19:50:57
DEATH reports that tg.exe kills any Replaygain tags added by FB2K if used after being RG tagged.
Title: mp4 command line tagger
Post by: Deep_Elem on 2005-01-28 21:57:23
What's the latest news on this tagger? Is it still in development? I downloaded tgutf.zip which contains tg.exe v0.38 Sept 12 2003. Is that the latest version?

Thanks in advance!
Title: mp4 command line tagger
Post by: bond on 2005-11-11 18:47:02
Quote
Quote
Please see if this works.  The only change was to try to add utf support, but I haven't tested much. 

http://users.rcn.com/rpritz/tgutf.zip (http://users.rcn.com/rpritz/tgutf.zip)

It works great! (w00t)

I've encoded and tagged 2 CDs with lots of accented chars.

iTunes got them all properly. Great job.

Now remains Joe with EphPod, he should handle UTF-8 so that I don't have to rename after transfer. 
[a href="index.php?act=findpost&pid=134139"][{POST_SNAPBACK}][/a]

here special characters, like ä ö ü are not displayed correctly
Title: mp4 command line tagger
Post by: bond on 2005-11-25 16:09:48
Quote
here special characters, like ä ö ü are not displayed correctly
[a href="index.php?act=findpost&pid=341149"][{POST_SNAPBACK}][/a]

thats because tg.exe does NOT do any conversion to utf-8. if you want your tags to be in correct utf-8 you need to feed tg.exe with utf-8 and this is NOT possible with .bat files (as these are stored as ANSI)

however there is a way to use windows to feed tg.exe with utf-8:
1) run the dos console (normally under start -> programs -> tools -> dos)
2) type
chcp 65001
which will change the console to use utf-8
3) go to the console settings and change from "rasterfont" to "lucida console" under "fonts"
4) type the commandline normally placed in your .bat file as always
5) enjoy your tags in correct utf-8 (also shown correctly in itunes/quicktime)

if you dont do this on windows you dont have your tags stored in utf-8 and quicktime/itunes doesnt display special characters correctly


apart from that someone warned me that tg is not save to use as it seems to fuck up some atoms, also if you tag a file multiple times with it you will get duplicate atoms (look at them in dumpster), so tg is propably not save to use

Quote
I don't have quicktime 7.03 installed, so I can't say anything about that, but I see you testing with the "tg" binary. You should be careful with it.

After some.... massaging, I managed to compile it on Mac OS X. First of all, if your udta atom (I think) is over 200,000 bytes it bombs out (easily fixed). But then it also strips all but a handful of atoms in "moov.udta.meta.ilst". Granted, most I don't care about. On a sample iTunes purchases song, it worked: worked at stripping 21 atoms to 7. And it removed my "covr.data" atom. Besides that, while it deleted those atoms, all it did was make a "free" atom: 460kb worth of null space. That amounted to 11% - a heavy price if you do it a huge number of files.

Not to berate the author of the software, because I know we all start somewhere, and it was a good crack at it, but just know that that tagger isn't idyllic (although none really are), and there are compromises in using that tg.exe tagger.
Title: mp4 command line tagger
Post by: anaxamander on 2005-11-26 02:54:02
Not that this currently works on Windows, but it does (mostly) work on Debian x86. I've tried compiling it under mingw in Win98SE under emulation, but I am unfamiliar with compiling in that environment. It's still a little broken under mingw. In any event, the source is up at http://sourceforge.net/projects/atomicparsley (http://sourceforge.net/projects/atomicparsley)

While not specifically coded for utf-8 support, at least on Mac OS X, it does support utf-8. Even japanese. There are some differences in what AtomicParsley does that iTunes doesn't. Currently all text tags are null terminated, while in iTunes, they aren't necessarily. And it sets tags that iTunes doesn't provide a way to alter (like lyric advisory & the new tv show atoms).

And apparently in cyrillic.

Edit2: a native win32 version is now available that will soon have feature-parity.
Title: mp4 command line tagger
Post by: emanation on 2005-12-26 15:19:28
Wow!

The cygwin version of AtomicParsley worked on 2 files but failed on an ateme mp4 - but then iTunes didn't like it before it was even touched.

Thanks.
Title: mp4 command line tagger
Post by: kwanbis on 2006-05-11 01:08:09
richard, i don't remember if already asked, but tg.exe always finish with an errorlevel of 1, when should be 0, any idea?