Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: mp4 command line tagger (Read 79044 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

mp4 command line tagger

Reply #25
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>


mp4 command line tagger

Reply #27
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.

mp4 command line tagger

Reply #28
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?

mp4 command line tagger

Reply #29
Quote
any chance of a gui/frontend...?

(  i know..)

Not from me :-)

Foobar's masstagger may be what you want

mp4 command line tagger

Reply #30
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

mp4 command line tagger

Reply #31
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.

mp4 command line tagger

Reply #32
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

mp4 command line tagger

Reply #33
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.

mp4 command line tagger

Reply #34
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

mp4 command line tagger

Reply #35
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

mp4 command line tagger

Reply #36
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;
}

mp4 command line tagger

Reply #37
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. It should work on Windows as well, but I haven't tried it there, only on Darwin and Linux.

mp4 command line tagger

Reply #38
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!

mp4 command line tagger

Reply #39
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.

mp4 command line tagger

Reply #40
Newer version of source is source
Windows exe at exe

mp4 command line tagger

Reply #41
>>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.

mp4 command line tagger

Reply #42
Quote
Newer version of source is source
Windows exe at exe

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: " 

mp4 command line tagger

Reply #43
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.

mp4 command line tagger

Reply #44
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.

mp4 command line tagger

Reply #45
Quote
Have you tried the new EphPod beta?   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!
-CyberInferno

mp4 command line tagger

Reply #46
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

mp4 command line tagger

Reply #47
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.

mp4 command line tagger

Reply #48
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.

mp4 command line tagger

Reply #49
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