getid3_ogg::Analyze() –

You appear to be a bot. Output may be restricted

Description

Usage

$bool = getid3_ogg::Analyze();

Parameters

Returns

bool

Source

File name: wordpress/wp-includes/ID3/module.audio.ogg.php
Lines:

301 to 383 of 383

      case 'opus':
        $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']);
        $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 0, 8); // hard-coded to 'OpusTags'
        if(substr($filedata, 0, 8)  != 'OpusTags') {
          $this->error('Expected "OpusTags" as header but got "'.substr($filedata, 0, 8).'"');
          return false;
        }

        $this->getid3_ogg::ParseVorbisComments();
        break;

    }

    // Last Page - Number of Samples
    if (!getid3_lib::intValueSupported($info['avdataend'])) {

      $this->warning('Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)');

    } else {

      $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')) {
        $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO')));
        $info['avdataend'] = $this->ftell();
        $info['ogg']['pageheader']['eos'] = $this->getid3_ogg::ParseOggPageHeader();
        $info['ogg']['samples']   = $info['ogg']['pageheader']['eos']['pcm_abs_position'];
        if ($info['ogg']['samples'] == 0) {
          $this->error('Corrupt Ogg file: eos.number of samples == zero');
          return false;
        }
        if (!empty($info['audio']['sample_rate'])) {
          $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']);
        }
      }

    }

    if (!empty($info['ogg']['bitrate_average'])) {
      $info['audio']['bitrate'] = $info['ogg']['bitrate_average'];
    } elseif (!empty($info['ogg']['bitrate_nominal'])) {
      $info['audio']['bitrate'] = $info['ogg']['bitrate_nominal'];
    } elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) {
      $info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2;
    }
    if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) {
      if ($info['audio']['bitrate'] == 0) {
        $this->error('Corrupt Ogg file: bitrate_audio == zero');
        return false;
      }
      $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate']);
    }

    if (isset($info['ogg']['vendor'])) {
      $info['audio']['encoder'] = preg_replace('/^Encoded with /', '', $info['ogg']['vendor']);

      // Vorbis only
      if ($info['audio']['dataformat'] == 'vorbis') {

        // Vorbis 1.0 starts with Xiph.Org
        if  (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) {

          if ($info['audio']['bitrate_mode'] == 'abr') {

            // Set -b 128 on abr files
            $info['audio']['encoder_options'] = '-b '.round($info['ogg']['bitrate_nominal'] / 1000);

          } elseif (($info['audio']['bitrate_mode'] == 'vbr') && ($info['audio']['channels'] == 2) && ($info['audio']['sample_rate'] >= 44100) && ($info['audio']['sample_rate'] <= 48000)) {
            // Set -q N on vbr files
            $info['audio']['encoder_options'] = '-q '.$this->getid3_ogg::get_quality_from_nominal_bitrate($info['ogg']['bitrate_nominal']);

          }
        }

        if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) {
          $info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps';
        }
      }
    }

    return true;
  }
 

 View on GitHub View on Trac