Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Czytanie tagów ID3v2
shinuexx
post
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 9
Dołączył: 2.02.2011
Skąd: undefined

Ostrzeżenie: (0%)
-----


Witam napisałem sobie własną funkcję do wyciągania tagów ID3v2 z plików mp3, ale mam pewien problem z niektórymi plikami. Zdarza się że czasem źle odczytuje rozmiar tagu i bądź też ramki (głównie przy GEOB oraz APIC). Podczas robienia podpierałem się trochę istniejącymi skryptami a strukturę tagu mam ze strony http://www.id3.org/. Poniżej przesyłam kod. Może gdzieś popełniłem błąd przy przetwarzaniu tagu. Mógłby ktoś na to spojrzećquestionmark.gif

  1. case 'APIC':
  2. $id3frame['encoding']=coding_table("coding",be2bin(substr($framedata,0,1)));
  3. $nullpos=strpos($framedata,chr(0),1);
  4. $id3frame['mime_type']=be2str(substr($framedata,1,$nullpos-1));
  5. $id3frame['mime_type']=@iconv(iconv_get_encoding($id3frame['mime_type']),"UTF-8",$id3frame['mime_type']);
  6. $id3frame['picture_type']=select_from_file_table(binhex(be2bin(substr($framedata,$nullpos+1,1))),"picture_type");
  7. $terminator=coding_table("terminator",be2bin(substr($framedata,0,1)));
  8. $terpos=strpos($framedata,$terminator,$nullpos+2);
  9. $id3frame['description']=be2str(substr($framedata,$nullpos+2,$terpos-$nullpos-2));
  10. $coding=be2bin(substr($framedata,0,1));
  11. if($coding==0x00)
  12. {
  13. $id3frame['description']=@iconv("ISO-8859-2","UTF-8",$id3frame['description']);
  14. }
  15. else
  16. {
  17. $id3frame['description']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['description']);
  18. }
  19. $id3frame['picture_data']=substr($framedata,$terpos+strlen($terminator));
  20.  
  21. break;
  22. case 'GEOB':
  23. $id3frame['encoding']=coding_table("coding",be2bin(substr($framedata,0,1)));
  24. $nullpos=strpos($framedata,chr(0),1);
  25. $id3frame['mime_type']=be2str(substr($framedata,1,$nullpos));
  26. $id3frame['mime_type']=@iconv("ISO-8859-2","UTF-8",$id3frame['mime_type']);
  27. $terminator=coding_table("terminator",be2bin(substr($framedata,0,1)));
  28. $terpos=strpos($framedata,$terminator,$nullpos+1);
  29. $id3frame['filename']=be2str(substr($framedata,$nullpos+1,$terpos-$nullpos-1));
  30. $coding=be2bin(substr($framedata,0,1));
  31. if($coding==0x00)
  32. {
  33. $id3frame['filename']=@iconv("ISO-8859-2","UTF-8",$id3frame['filename']);
  34. }
  35. else
  36. {
  37. $id3frame['filename']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['filename']);
  38. }
  39. $terpos2=strpos($framedata,$terminator,$terpos+strlen($terminator));
  40. $id3frame['content_description']=be2str(substr($framedata,$terpos+strlen($terminator),$terpos2-$terpos-strlen($terminator)));
  41. if($coding==0x00)
  42. {
  43. $id3frame['filename']=@iconv("ISO-8859-2","UTF-8",$id3frame['filename']);
  44. }
  45. else
  46. {
  47. $id3frame['filename']=@iconv($id3frame['encoding'],"UTF-8",$id3frame['filename']);
  48. }
  49. $id3frame['encapsuled_object']=substr($framedata,$terpos2+strlen($terminator));
  50. break;



Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




http://forum.php.pl/index.php?showtopic=169232


--------------------
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 23:57