module.audio-video.bink.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at https://github.com/JamesHeinrich/getID3 //
  5. // or https://www.getid3.org //
  6. // or http://getid3.sourceforge.net //
  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. if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
  16. exit;
  17. }
  18. class getid3_bink extends getid3_handler
  19. {
  20. /**
  21. * @return bool
  22. */
  23. public function Analyze() {
  24. $info = &$this->getid3->info;
  25. $this->error('Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']');
  26. $this->fseek($info['avdataoffset']);
  27. $fileTypeID = $this->fread(3);
  28. switch ($fileTypeID) {
  29. case 'BIK':
  30. return $this->ParseBink();
  31. case 'SMK':
  32. return $this->ParseSmacker();
  33. default:
  34. $this->error('Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"');
  35. return false;
  36. }
  37. }
  38. /**
  39. * @return bool
  40. */
  41. public function ParseBink() {
  42. $info = &$this->getid3->info;
  43. $info['fileformat'] = 'bink';
  44. $info['video']['dataformat'] = 'bink';
  45. $fileData = 'BIK'.$this->fread(13);
  46. $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
  47. $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
  48. if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
  49. $this->error('Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']));
  50. }
  51. return true;
  52. }
  53. /**
  54. * @return bool
  55. */
  56. public function ParseSmacker() {
  57. $info = &$this->getid3->info;
  58. $info['fileformat'] = 'smacker';
  59. $info['video']['dataformat'] = 'smacker';
  60. return true;
  61. }
  62. }