module.audio-video.bink.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 extends getid3_handler
  16. {
  17. function Analyze() {
  18. $info = &$this->getid3->info;
  19. $info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']';
  20. fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
  21. $fileTypeID = fread($this->getid3->fp, 3);
  22. switch ($fileTypeID) {
  23. case 'BIK':
  24. return $this->ParseBink();
  25. break;
  26. case 'SMK':
  27. return $this->ParseSmacker();
  28. break;
  29. default:
  30. $info['error'][] = 'Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"';
  31. return false;
  32. break;
  33. }
  34. return true;
  35. }
  36. function ParseBink() {
  37. $info = &$this->getid3->info;
  38. $info['fileformat'] = 'bink';
  39. $info['video']['dataformat'] = 'bink';
  40. $fileData = 'BIK'.fread($this->getid3->fp, 13);
  41. $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
  42. $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
  43. if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
  44. $info['error'][] = 'Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']);
  45. }
  46. return true;
  47. }
  48. function ParseSmacker() {
  49. $info = &$this->getid3->info;
  50. $info['fileformat'] = 'smacker';
  51. $info['video']['dataformat'] = 'smacker';
  52. return true;
  53. }
  54. }
  55. ?>