update mp3scan & update seeking for mpeg header
This commit is contained in:
parent
fd4a4ed97d
commit
89fac15d4f
@ -140,9 +140,9 @@ class Mp3InfoConsoleRunner {
|
||||
self::formatTime($audio->duration),
|
||||
$audio->isVbr ? 'vbr' : ($audio->bitRate / 1000).'kbps',
|
||||
($audio->sampleRate / 1000),
|
||||
isset($audio->tags1['song']) ? self::substrIfLonger($audio->tags1['song'], 11) : null,
|
||||
isset($audio->tags1['artist']) ? self::substrIfLonger($audio->tags1['artist'], 10) : null,
|
||||
isset($audio->tags1['track']) ? self::substrIfLonger($audio->tags1['track'], 5) : null,
|
||||
isset($audio->tags['song']) ? self::substrIfLonger($audio->tags['song'], 11) : null,
|
||||
isset($audio->tags['artist']) ? self::substrIfLonger($audio->tags['artist'], 10) : null,
|
||||
isset($audio->tags['track']) ? self::substrIfLonger($audio->tags['track'], 5) : null,
|
||||
$audio->_parsingTime)
|
||||
.PHP_EOL;
|
||||
|
||||
|
@ -304,16 +304,22 @@ class Mp3Info {
|
||||
$header_seek_pos = ftell($fp) + self::$headerSeekLimit;
|
||||
do {
|
||||
$pos = ftell($fp);
|
||||
$first_header_byte = $this->readBytes($fp, 4);
|
||||
$first_header_byte = $this->readBytes($fp, 1);
|
||||
if ($first_header_byte[0] === 0xFF) {
|
||||
fseek($fp, $pos);
|
||||
$header_bytes = $this->readBytes($fp, 4);
|
||||
break;
|
||||
$second_header_byte = $this->readBytes($fp, 1);
|
||||
if ((($second_header_byte[0] >> 5) & 0b111) == 0b111) {
|
||||
fseek($fp, $pos);
|
||||
$header_bytes = $this->readBytes($fp, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fseek($fp, 1, SEEK_CUR);
|
||||
} while (ftell($fp) <= $header_seek_pos);
|
||||
|
||||
if ($header_bytes[0] !== 0xFF || (($header_bytes[1] >> 5) & 0b111) != 0b111) throw new \Exception("At ".$pos."(0x".dechex($pos).") should be a frame header!");
|
||||
if (!isset($header_bytes) || $header_bytes[0] !== 0xFF || (($header_bytes[1] >> 5) & 0b111) != 0b111) {
|
||||
throw new \Exception('At '.$pos
|
||||
.'(0x'.dechex($pos).') should be a frame header!');
|
||||
}
|
||||
|
||||
switch ($header_bytes[1] >> 3 & 0b11) {
|
||||
case 0b00: $this->codecVersion = self::MPEG_25; break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user