Hi all =)
I have used getid3() in my script (file manager)
its perfect, thanks for your work!
but...
my script store uploaded files on the server in FS structure like this:
files/u/s/e/r/i/d/fileID_unix_timestamp.dlfile (vBulletin like attachment structure)
and store the real information about this file in the Data Base (MySQL) - real filename, stored filename, filesize, real file extension (mp3 for example) etc
in basically the getid3() read information good, but sometimes (i can't understand why) the array $ThisFileInfo['comments_html'] is empty with stored file extension (.dlfile - not mp3) =\
i found the solution (ugly =\), to copy file with real extension in the temp dir =>
read ID3 info (getid3()) =>
store info into array $ThisFileInfo['comments_html'] =>
delete temp file =>
print id3 info on the page or store this info into DB
=
can someone explain, why this happens? =)
detect id3 tags in files with no extension or other ext
-
- User
- Posts:4
- Joined:Mon Sep 05, 2011 11:25 pm
- Are you a spambot?:no
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: detect id3 tags in files with no extension or other ext
Tag metadata (ID3v2, ID3v1, APE, Lyrics3) should always be read. The file may not be detected as an mp3 file if it sufficiently corrupted (random null or garbage data at beginning of file, or between end of ID3v2 and beginning of audio data). Unfortunately this kind of corruption is very common (see "Known Bugs/Issues in other programs" at the end of the readme).
getID3 hacks around this problem of "undetectable" file formats by doing a brute force scan of the file under the assumption that it's a broken MP3 file if the filename ends in ".mp3" (actually .mp3 or .mp2 or .mp1 or .mpa). See function GetFileFormat() in getid3.php (around lines 1130-1165 in v1.9.1).
getID3 hacks around this problem of "undetectable" file formats by doing a brute force scan of the file under the assumption that it's a broken MP3 file if the filename ends in ".mp3" (actually .mp3 or .mp2 or .mp1 or .mpa). See function GetFileFormat() in getid3.php (around lines 1130-1165 in v1.9.1).
-
- User
- Posts:4
- Joined:Mon Sep 05, 2011 11:25 pm
- Are you a spambot?:no
Re: detect id3 tags in files with no extension or other ext
thank you for replay, James =)
==
before open a new thread I have carefully examined the files and getid3.php getid3.lib.php including you specified function (GetFileFormat())
and have no idea, how to make the function work =)
ok, i show you small debug in the screen (my english is very bad)...
and now, i rename the file and run the script again....
it is same file, but only renamed =)
the getid3() read info from file, not by extension, right?
where i'm wrong? =)
==
before open a new thread I have carefully examined the files and getid3.php getid3.lib.php including you specified function (GetFileFormat())
and have no idea, how to make the function work =)
ok, i show you small debug in the screen (my english is very bad)...
Code: Select all
$getID3 = new getID3;
$FullFileName = 'K:/MUSIC/Galka/A.Celentano - Susanna.mp3';
$ThisFileInfo = $getID3->analyze($FullFileName);
getid3_lib::CopyTagsToComments($ThisFileInfo);
print '<pre>';
print_r($ThisFileInfo);
print '</pre>';
Code: Select all
$getID3 = new getID3;
$FullFileName = 'K:/MUSIC/Galka/A.Celentano - Susanna.dlfile';
$ThisFileInfo = $getID3->analyze($FullFileName);
getid3_lib::CopyTagsToComments($ThisFileInfo);
print '<pre>';
print_r($ThisFileInfo);
print '</pre>';
the getid3() read info from file, not by extension, right?
where i'm wrong? =)
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: detect id3 tags in files with no extension or other ext
If you look at the two files: the one on the left was encoded by a "bad" version of LAME (v3.92 DLL) and the one on the right was encoded with a fixed version (v3.93).
You can see the beginning of the "bad" file consists of nothing but nulls (00) for the entire first frame of the file (417 bytes), but the "good" file starts with the MP3 header (FF FB 94 44 in this case), and also contains other data in the Xing/LAME header section. Because there's nothing at the beginning of the bad file, it's impossible to know what kind of file it is. What getID3 does when checking files is basically this:Code: Select all
foreach (<known file types>) {
if (<first few bytes of file> = <known file pattern>) {
return analyze_file_as(found_file_type);
}
}
// failed to match any known file types
if (<filename> like ".mp3") {
return analyze_file_as(MP3);
} else {
return false;
}
-
- User
- Posts:4
- Joined:Mon Sep 05, 2011 11:25 pm
- Are you a spambot?:no
Re: detect id3 tags in files with no extension or other ext
yes, i see this function =)
but if function modified like this:
this returned correct tags and all data...
and... beginning of the file looks correct, no "zero" bytes
if you want, you can analize one of this "bad" files (uploaded to depositfiles)
http://depositfiles.com/files/g40jakm3v
thanks for your replies =)
but if function modified like this:
Code: Select all
foreach (<known file types>) {
if (<first few bytes of file> = <known file pattern>) {
return analyze_file_as(found_file_type);
}
}
// failed to match any known file types
if (<filename> like ".mp3") {
return analyze_file_as(MP3);
}
else if(preg_match('#\.dlfile$#i', $filename))
{
$GetFileFormatArray = $this->GetFileFormatArray();
$info = $GetFileFormatArray['mp3'];
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
return $info;
} else {
return false;
}
and... beginning of the file looks correct, no "zero" bytes
if you want, you can analize one of this "bad" files (uploaded to depositfiles)
http://depositfiles.com/files/g40jakm3v
thanks for your replies =)
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: detect id3 tags in files with no extension or other ext
By "beginning of file", I mean after the ID3v2 tag is removed from the beginning (and ID3v1/APE/Lyrics3 from the end).
As I suspected, if you look at the returned warning for that file:
As I suspected, if you look at the returned warning for that file:
Unknown data before synch (ID3v2 header ends at 3635, then 626 bytes garbage, synch detected at 4261). This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.
-
- User
- Posts:4
- Joined:Mon Sep 05, 2011 11:25 pm
- Are you a spambot?:no
Re: detect id3 tags in files with no extension or other ext
ok, you are right =)
i will copy file to tmp location with real ext and then process with getid3()
thanks again
kerk
i will copy file to tmp location with real ext and then process with getid3()
thanks again
kerk