Problem writing to multiple MP3s

The place for "I can't figure out how to..." questions.
Post Reply
Lomaxfairchild
User
Posts: 2
Joined: Tue Jul 12, 2005 9:08 am

Problem writing to multiple MP3s

Post by Lomaxfairchild » Tue Jul 12, 2005 9:15 am

Hi

I have a directory of MP3s I want to loop through, changing their ID3 tags.

I've got the code to work on the first file, however for subsequent files I get the following error repeated:


DeleteAPEtag() failed with message(s):

*



WriteID3v2() failed with message(s):

* Only one COMM tag allowed with the same Language + Description (eng + )
* Frame "COMM" is NOT allowed
* $this->GenerateID3v2FrameData() failed for "COMM"
* $this->GenerateID3v2Tag() failed

Failed to write tags!

I'm not resetting the ID3 object (thought I have tried this and it made no difference)

Is there anything special I should know about looping through files?

I'm using PHP 4.3.10, getID3 1.74 and get the same error on my Windows box and an OS X machine.

Any hints much appreciated - I was up till 3.30 last night trying to sort this out!

[edit]

I only get the error when I set the comments - otherwise it works ok.

Lomaxfairchild
User
Posts: 2
Joined: Tue Jul 12, 2005 9:08 am

Post by Lomaxfairchild » Tue Jul 12, 2005 12:28 pm

Classic case of PEBCAK

I copied and pasted the code and was forgetting to reset the $TagData array for each file.

chulo
User
Posts: 1
Joined: Mon Jan 07, 2008 6:12 am

same problem

Post by chulo » Mon Jan 07, 2008 8:45 am

How did you solve this problem can you gave me a script example, where and how to reset $tag_data because i'm have the same problem and don't know how to fix it.

thank you

Code: Select all




 foreach($_POST['music_option'] as $key_song => $value) {
    $music_option[$key_song] = stripinput($_POST['music_option'][$key_song]);
                                
    $getID3 = new getID3;
    $getID3->setOption(array('encoding'=>$TaggingFormat)); 
                             
    require_once INCLUDES."getid3/write.php"; 
                               
    // Initialize getID3 tag-writing module
   $tagwriter = new getid3_writetags;
   $tagwriter->filename       = $music_option[$key_song];
   $tagwriter->tagformats     = array('id3v1', 'id3v2.3');

    // set various options (optional)
    $tagwriter->overwrite_tags = true;
    $tagwriter->tag_encoding   = $TaggingFormat;
    $tagwriter->remove_other_tags = true;

     // populate data array
     $TagData['title'][]   = $music_option2[$key_song];
     $TagData['artist'][]  = $music_artist[$key_song];
     $TagData['album'][]   = $music_album[$key_song];
     $TagData['year'][]    = '2007';
     $TagData['genre'][]   = 'Rock';
     $TagData['comment'][] = 'excellent!';
     $TagData['track'][]   = $music_track[$key_song];

     $tagwriter->tag_data = $TagData;

     // write tags
     if ($tagwriter->WriteTags()) {
             echo 'Successfully wrote tags<br>';
             if (!empty($tagwriter->warnings)) {
                     echo 'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
             }
      } else {
             echo 'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);
                                }
      }

Post Reply