diff --git a/getid3/getid3.php b/getid3/getid3.php index 6a17cb04..94fb322f 100644 --- a/getid3/getid3.php +++ b/getid3/getid3.php @@ -387,7 +387,7 @@ class getID3 */ protected $startup_warning = ''; - const VERSION = '1.9.23-202408061058'; + const VERSION = '1.9.23-202408081349'; const FREAD_BUFFER_SIZE = 32768; const ATTACHMENTS_NONE = false; diff --git a/getid3/module.audio.ogg.php b/getid3/module.audio.ogg.php index ebd2b946..06452cbc 100644 --- a/getid3/module.audio.ogg.php +++ b/getid3/module.audio.ogg.php @@ -350,6 +350,12 @@ public function Analyze() { $this->fseek(max($info['avdataend'] - $this->getid3->fread_buffer_size(), 0)); $LastChunkOfOgg = strrev($this->fread($this->getid3->fread_buffer_size())); if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) { + if (substr($LastChunkOfOgg, 13, 8) === "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF") { + // https://github.com/JamesHeinrich/getID3/issues/450 + // "Sometimes, Opus encoders (WhatsApp voice registrations and others) add a special last header with a granule duration of 0xFFFFFFFFFFFFFF. + // This value indicates "this is the end," but must be ignored; otherwise, it makes calculations wrong." + $LastOggSpostion = strpos($LastChunkOfOgg, 'SggO', $LastOggSpostion + 1); + } $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO'))); $info['avdataend'] = $this->ftell(); $info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader();