Problems copying tags

The place for "I can't figure out how to..." questions.
Post Reply
Posts: 10
Joined: Wed Jul 19, 2006 3:48 am

Problems copying tags

Post by nitro322 » Sun Jul 30, 2006 8:14 am

I've written a script that transcodes a collection of FLAC files to either Ogg Vorbis or MP3 (depending on the options selected). I then use getID3() to copy the tags from the original FLAC file to the new file. When writing to Ogg files, this works perfectly fine; however, when writing to MP3 files the WriteTags() function fails with no error message.

I've tried playing around with various different options and variations, but so far I haven't been able to figure out what's causing the problem. The fact that it works perfectly with Ogg Vorbis is really puzzling. Does anyone know what might cause this issue?

Here's a snippit of the relavant code:

Code: Select all

# Initialize getID3()
$getid3 = "/home/user/bin/getid3/getid3.php";
$getID3 = new getID3;
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__);
$tagwriter = new getid3_writetags;
$tagwriter->tag_encoding = 'UTF-8';
$tagwriter->overwrite_tags = true;
$tagwriter->remove_other_tags = true;
if ($format == 'ogg')
    $tagwriter->tagformats = array('vorbiscomment');
elseif ($format == 'mp3')
    $tagwriter->tagformats = array('id3v1', 'id3v2.3');

# Begin processing individual files files
foreach ($flacs as $file) {
    # Read tag info
    $tags = $getID3->analyze($file);

    # Convert song
    passthru("$flac $flacargs \"$file\" | $encoder");

    # Write tag info
    $tagwriter->filename = "$dirname/$filename";
    $tagwriter->tag_data = $tags['comments'];
    if (!$tagwriter->WriteTags())
        echo "\nfailure - ".strip_tags(implode($tagwriter->errors))."\n";
As I said, this works perfectly with Ogg Vorbis, but fails with MP3. The failure message is echoed, but no actual error message is displayed, only "failure - ".

Any help would be much appreciated. Thanks.

Posts: 10
Joined: Wed Jul 19, 2006 3:48 am

Post by nitro322 » Mon Jul 31, 2006 3:37 am

Hmm... it turns out this isn't working quite right with Ogg Vorbis either. For example, here are the tags from the original FLAC file:

Code: Select all

$ metaflac --list --block-number=2 01-Kryptonite.flac
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 293
  vendor string: reference libFLAC 1.1.2 20050205
  comments: 10
    comment[0]: ARTIST=3 Doors Down
    comment[1]: ALBUM=The Better Life
    comment[2]: TITLE=Kryptonite
    comment[3]: DATE=1999
    comment[4]: TRACKNUMBER=01
    comment[5]: GENRE=Rock
    comment[6]: REPLAYGAIN_TRACK_PEAK=0.95587158
    comment[7]: REPLAYGAIN_TRACK_GAIN=-8.94 dB
    comment[8]: REPLAYGAIN_ALBUM_PEAK=0.98068237
    comment[9]: REPLAYGAIN_ALBUM_GAIN=-9.24 dB
Next, here are the tags from the transcoded Ogg file:

Code: Select all

$ vorbiscomment -l 01-Kryptonite.ogg
ARTIST=3 Doors Down
ALBUM=The Better Life
As you can see, it did not copy over the ReplayGain tags. I guess the way I'm currently trying to call it will only copy over "standard" tags (ARTIST, ALBUM, etc.).

So... can anyone recommend a better way of doing this? I'm still very new to getID3(), so I'm sure the problem here exists squarely between the keyboard and chair. :-) Any assistance would be much appreciated.


Post Reply