module.audio-video.bink.php 2.3 KB

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