I need a suggestion

The place for "I can't figure out how to..." questions.
Post Reply
Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

I need a suggestion

Post by Bigun » Fri Jun 23, 2006 6:25 pm

What do I need to simply verify that a file that was uploaded is in fact and MP3 (either by ID3 tag or some other method)?

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Fri Jun 23, 2006 11:06 pm

ID3 tag says nothing about the file.


Look for ['fileformat'] == 'mp3'

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Wed Aug 30, 2006 5:15 pm

This is weird...

I have an MP3 that plays fine... but ID3's "fileformat" function only spits out null.

If I upload another different MP3, it spits out 'mp3' as the file format.
Last edited by Bigun on Wed Aug 30, 2006 6:58 pm, edited 1 time in total.

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Wed Aug 30, 2006 5:23 pm

Code: Select all

$fileinfo['error'];
and

Code: Select all

$fileinfo['warning'];
Show nothing, they are empty.

*EDIT*

They are not empty:

Code: Select all

unable to determine file format
Some ID3v1 fields do not use NULL characters for padding

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Wed Aug 30, 2006 6:31 pm

As a final hoo-rah, I figure I would post the code I am using:

Code: Select all

//Song Present - Run Tests
// include getID3() library (can be in a different directory if full path is specified)
require_once('./getid3/getid3.php');

// Initialize getID3 engine
$getID3 = new getID3;

// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze($$currsongfile);

// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);

// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
$format=@$ThisFileInfo['fileformat'];
$fileformaterror=@$ThisFileInfo['error'];
$fileformatwarning=@$ThisFileInfo['warning'];
if ($format != "mp3") {
     //The file has no valid bitrate or no valid time or isn't an MP3 - reject
}

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Wed Aug 30, 2006 11:39 pm

If you can't figure it out, email a link to the supposedly-mp3 file in question and I'll tell you what's wrong with it: info@getid3.org

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Thu Aug 31, 2006 11:53 am

James Heinrich wrote:If you can't figure it out, email a link to the supposedly-mp3 file in question and I'll tell you what's wrong with it: info at getid3 dot org
Sent

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Fri Sep 01, 2006 1:44 am

Did you get my e-mail?

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Fri Sep 01, 2006 2:22 am

I ran it through getID3() and it seems to scan fine:
http://www.getid3.org/temp/T3CHN0PH0B1A ... fleet.html

The only thing to notice is the warning:
Unknown data before synch (ID3v2 header ends at 1284, then 10 bytes garbage, synch detected at 1294)
That means that whatever broken program used to create the ID3v2 tag wrote 10 bytes of garbage data, which prevents simple detection of the MP3 (getID3() need to go into extended scan mode to find the MP3 data). By default, getID3() only does this extended scanning on files that don't match any other known data pattern (first check), and are named *.mp3 (second check). So to make getID3 recognize even broken MP3s, make sure the names of the files you're scanning end in .mp3 (doesn't matter if they're not actually MP3s, getID3 won't be fooled).

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Fri Sep 01, 2006 1:39 pm

Ahh...

I was running as through with the temp filename that PHP gave it. Some md5 garbage. I'll just slap the '.mp3' on the end and see what happens.

Bigun
User
Posts: 8
Joined: Fri Jun 23, 2006 5:48 pm

Post by Bigun » Mon Sep 04, 2006 10:23 pm

That was it..

Post Reply