parseSTREAMINFOdata example

$info['audio']['lossless']     = true;

            $info['ogg']['flac']['header']['version_major']  =                         ord(substr($filedata,  5, 1));
            $info['ogg']['flac']['header']['version_minor']  =                         ord(substr($filedata,  6, 1));
            $info['ogg']['flac']['header']['header_packets'] =   getid3_lib::BigEndian2Int(substr($filedata,  7, 2)) + 1; // "A two-byte, big-endian binary number signifying the number of header (non-audio) packets, not including this one. This number may be zero (0x0000) to signify 'unknown' but be aware that some decoders may not be able to handle such streams."             $info['ogg']['flac']['header']['magic']          =                             substr($filedata,  9, 4);
            if ($info['ogg']['flac']['header']['magic'] != 'fLaC') {
                $this->error('Ogg-FLAC expecting "fLaC", found "'.$info['ogg']['flac']['header']['magic'].'" ('.trim(getid3_lib::PrintHexBytes($info['ogg']['flac']['header']['magic'])).')');
                return false;
            }
            $info['ogg']['flac']['header']['STREAMINFO_bytes'] = getid3_lib::BigEndian2Int(substr($filedata, 13, 4));
            $info['flac']['STREAMINFO'] = getid3_flac::parseSTREAMINFOdata(substr($filedata, 17, 34));
            if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {
                $info['audio']['bitrate_mode']    = 'vbr';
                $info['audio']['sample_rate']     = $info['flac']['STREAMINFO']['sample_rate'];
                $info['audio']['channels']        = $info['flac']['STREAMINFO']['channels'];
                $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
                $info['playtime_seconds']         = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
            }

        } else {

            $this->error('Expecting one of "vorbis", "Speex", "OpusHead", "vorbis", "fishhead", "theora", "fLaC" identifier strings, found "'.substr($filedata, 0, 8).'"');
            
return $streaminfo;
    }

    /** * @param string $BlockData * * @return bool */
    private function parseSTREAMINFO($BlockData) {
        $info = &$this->getid3->info;

        $info['flac']['STREAMINFO'] = self::parseSTREAMINFOdata($BlockData);

        if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {

            $info['audio']['bitrate_mode']    = 'vbr';
            $info['audio']['sample_rate']     = $info['flac']['STREAMINFO']['sample_rate'];
            $info['audio']['channels']        = $info['flac']['STREAMINFO']['channels'];
            $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
            $info['playtime_seconds']         = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
            if ($info['playtime_seconds'] > 0) {
                if (!$this->isDependencyFor('matroska')) {
                    $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
                }
Home | Imprint | This part of the site doesn't use cookies.