module.audio-video.bink.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at http://getid3.sourceforge.net //
  5. // or http://www.getid3.org //
  6. /////////////////////////////////////////////////////////////////
  7. // See readme.txt for more details //
  8. /////////////////////////////////////////////////////////////////
  9. // //
  10. // module.audio.bink.php //
  11. // module for analyzing Bink or Smacker audio-video files //
  12. // dependencies: NONE //
  13. // ///
  14. /////////////////////////////////////////////////////////////////
  15. class getid3_bink
  16. {
  17. function getid3_bink(&$fd, &$ThisFileInfo) {
  18. $ThisFileInfo['error'][] = 'Bink / Smacker files not properly processed by this version of getID3()';
  19. fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
  20. $fileTypeID = fread($fd, 3);
  21. switch ($fileTypeID) {
  22. case 'BIK':
  23. return $this->ParseBink($fd, $ThisFileInfo);
  24. break;
  25. case 'SMK':
  26. return $this->ParseSmacker($fd, $ThisFileInfo);
  27. break;
  28. default:
  29. $ThisFileInfo['error'][] = 'Expecting "BIK" or "SMK" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$fileTypeID.'"';
  30. return false;
  31. break;
  32. }
  33. return true;
  34. }
  35. function ParseBink(&$fd, &$ThisFileInfo) {
  36. $ThisFileInfo['fileformat'] = 'bink';
  37. $ThisFileInfo['video']['dataformat'] = 'bink';
  38. $fileData = 'BIK'.fread($fd, 13);
  39. $ThisFileInfo['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
  40. $ThisFileInfo['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
  41. if (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) != ($ThisFileInfo['bink']['data_size'] + 8)) {
  42. $ThisFileInfo['error'][] = 'Probably truncated file: expecting '.$ThisFileInfo['bink']['data_size'].' bytes, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
  43. }
  44. return true;
  45. }
  46. function ParseSmacker(&$fd, &$ThisFileInfo) {
  47. $ThisFileInfo['fileformat'] = 'smacker';
  48. $ThisFileInfo['video']['dataformat'] = 'smacker';
  49. return false;
  50. }
  51. }
  52. ?>