how to write 'ownerid' & 'data' into the 'private frame'

The place for "I can't figure out how to..." questions.
Post Reply
Posts: 16
Joined: Thu Feb 02, 2006 3:19 pm

how to write 'ownerid' & 'data' into the 'private frame'

Post by » Sun Feb 19, 2006 11:24 am


I need to write / save own data into mp3 files so I guess I have to use the "Private frame" (PRIV) for that but I don't know how to do it right - whenever I try to write ('ownerid' & 'data') I'm getting "Successfully wrote tags" but when I read out all tags I can't find the data I used for testing ... could someone please help me with this?

this is my code:
$TaggingFormat = 'UTF-8';
// Initialize getID3 engine
$getID3 = new getID3;
$getID3->encoding = $TaggingFormat;

// Initialize getID3 tag-writing module
$tagwriter = new getid3_writetags;

$tagwriter->filename = $filename;
$tagwriter->tagformats = array('id3v2.4');

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

now I don't know where to write it to:

$TagData['id3v2']['PRIV']['ownerid'] = "";
$TagData['id3v2']['PRIV']['data'] = "test-data-test";

$TagData['id3v2']['comments']['private']['ownerid'] = "";
$TagData['id3v2']['comments']['private']['ownerid'] = "test-data-test";

$TagData['mpeg']['audio']['LAME']['private']['ownerid'] = "";
$TagData['mpeg']['audio']['LAME']['private']['data'] = "test-data-test";

# write tags
$tagwriter->tag_data = $TagData;

it's about this frame:
4.27. Private frame

This frame is used to contain information from a software producer
that its program uses and does not fit into the other frames. The
frame consists of an 'Owner identifier' string and the binary data.
The 'Owner identifier' is a null-terminated string with a URL [URL]
containing an email address, or a link to a location where an email
address can be found, that belongs to the organisation responsible
for the frame. Questions regarding the frame should be sent to the
indicated email address. The tag may contain more than one "PRIV"
frame but only with different contents.

<Header for 'Private frame', ID: "PRIV">
Owner identifier <text string> $00
The private data <binary data>
how does getid3 handle it? is it linked to another frame?
The "PRIV" frame may be linked with the owner identifier as
additional ID data.
thanks for helping!

Posts: 2
Joined: Mon Feb 27, 2006 4:53 am

Had the same problem...

Post by jenUnderscore_ » Mon Feb 27, 2006 4:57 am

Here's the solution:

Code: Select all

		$getID3 = new getID3;
		getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.id3v2.php', __FILE__, true); 
		$TaggingFormat = 'UTF-8';
		$tagwriter = new getid3_write_id3v2();
		$tagwriter->filename = $fileName;
		$tagwriter->filename = $fileName;
		$tagwriter->tagformats     = array('id3v1', 'id3v2.3');

		// set various options (optional)
		$tagwriter->overwrite_tags = true;
		$tagwriter->tag_encoding   = $TaggingFormat;
		$tagwriter->remove_other_tags = true;
		$TagData['PRIV'][0]['ownerid'] = '';
		$TagData['PRIV'][0]['data'] = "whatever";
		$tagwriter->tag_data = $TagData;
		if ($tagwriter->WriteID3v2()) {
			echo 'Successfully wrote tags<BR>';
			if (!empty($tagwriter->warnings)) {
				echo 'There were some warnings:<BLOCKQUOTE STYLE="background-color:#FFCC33; padding: 10px;">'.implode('<BR><BR>', $tagwriter->warnings).'</BLOCKQUOTE>';
		} else {
			echo 'Failed to write tags!<BLOCKQUOTE STYLE="background-color:#FF9999; padding: 10px;">'.implode('<BR><BR>', $tagwriter->errors).'</BLOCKQUOTE>';

Thanks to this thread for the answer :

The answer is to not use the write.php script and access the write.id3v2.php script directly
Posts: 16
Joined: Thu Feb 02, 2006 3:19 pm

thank you!

Post by » Mon Feb 27, 2006 10:12 am

thanks a lot, jenUnderscore_!

Post Reply