PrintHexBytes example

$this->readBinDataOffset = 32;

        } elseif ($this->isDependencyFor('matroska')) {

            // Matroska contains DTS without syncword encoded as raw big-endian format             $encoding = 0;
            $this->readBinDataOffset = 0;

        } else {

            unset($info['fileformat']);
            return $this->error('Expecting "'.implode('| ', array_map('getid3_lib::PrintHexBytes', self::$syncwords)).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($sync).'"');

        }

        // decode header         $fhBS = '';
        for ($word_offset = 0; $word_offset <= strlen($DTSheader)$word_offset += 2) {
            switch ($encoding) {
                case 0: // raw big-endian                     $fhBS .=        getid3_lib::BigEndian2Bin(       substr($DTSheader$word_offset, 2) );
                    break;
                case 1: // raw little-endian
const syncword = 'fLaC';

    /** * @return bool */
    public function Analyze() {
        $info = &$this->getid3->info;

        $this->fseek($info['avdataoffset']);
        $StreamMarker = $this->fread(4);
        if ($StreamMarker != self::syncword) {
            return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"');
        }
        $info['fileformat']            = 'flac';
        $info['audio']['dataformat']   = 'flac';
        $info['audio']['bitrate_mode'] = 'vbr';
        $info['audio']['lossless']     = true;

        // parse flac container         return $this->parseMETAdata();
    }

    /** * @return bool */
                                $info['matroska']['tracks'] = $element_data;

                                while ($this->getEBMLelement($track_entry$element_data['end'])) {
                                    switch ($track_entry['id']) {

                                        case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
                                            while ($this->getEBMLelement($subelement$track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS, EBML_ID_CODECPRIVATE))) {
                                                switch ($subelement['id']) {

                                                    case EBML_ID_TRACKUID:
                                                        $track_entry[$subelement['id_name']] = getid3_lib::PrintHexBytes($subelement['data'], true, false);
                                                        break;
                                                    case EBML_ID_TRACKNUMBER:
                                                    case EBML_ID_TRACKTYPE:
                                                    case EBML_ID_MINCACHE:
                                                    case EBML_ID_MAXCACHE:
                                                    case EBML_ID_MAXBLOCKADDITIONID:
                                                    case EBML_ID_DEFAULTDURATION: // nanoseconds per frame                                                         $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
                                                        break;

                                                    case EBML_ID_TRACKTIMECODESCALE:
                                                        
// https://xiph.org/flac/ogg_mapping.html
            $info['audio']['dataformat']   = 'flac';
            $info['audio']['bitrate_mode'] = 'vbr';
            $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'];
            }

        }
if ($boxsmallsize <= 1) {
                                    $this->warning('Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset));
                                    $atom_structure['data'] = null;
                                    $atomoffset = strlen($atom_data);
                                    break;
                                }
                                switch ($boxsmalltype) {
                                    case "\x10\xB5":
                                        $atom_structure['data'] = $boxsmalldata;
                                        break;
                                    default:
                                        $this->warning('Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset);
                                        $atom_structure['data'] = $atom_data;
                                        break;
                                }
                                $atomoffset += (4 + $boxsmallsize);
                            }
                        } else {
                            while ($atomoffset < strlen($atom_data)) {
                                $boxsize = getid3_lib::BigEndian2Int(substr($atom_data$atomoffset, 4));
                                $boxtype =                           substr($atom_data$atomoffset + 4, 4);
                                $boxdata =                           substr($atom_data$atomoffset + 8, $boxsize - 8);
                                if ($boxsize <= 1) {
                                    
$this->fseek($info['avdataoffset']);

        $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
        $FLVheader = $this->fread(5);

        $info['fileformat'] = 'flv';
        $info['flv']['header']['signature'] =                           substr($FLVheader, 0, 3);
        $info['flv']['header']['version']   = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
        $TypeFlags                          = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));

        if ($info['flv']['header']['signature'] != self::magic) {
            $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"');
            unset($info['flv']$info['fileformat']);
            return false;
        }

        $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
        $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);

        $FrameSizeDataLength = getid3_lib::BigEndian2Int($this->fread(4));
        $FLVheaderFrameLength = 9;
        if ($FrameSizeDataLength > $FLVheaderFrameLength) {
            $this->fseek($FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
        }
default:
                            if ($info['filesize'] == ($chunkdata['offset'] - 8 + 128)) {
                                $DIVXTAG = $nextRIFFheader.$this->fread(128 - 12);
                                if (substr($DIVXTAG, -7) == 'DIVXTAG') {
                                    // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file                                     $this->warning('Found wrongly-structured DIVXTAG at offset '.($this->ftell() - 128).', parsing anyway');
                                    $info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG);
                                    break 2;
                                }
                            }
                            $this->warning('Expecting "RIFF|JUNK|IDVX" at '.$nextRIFFoffset.', found "'.$nextRIFFheaderID.'" ('.getid3_lib::PrintHexBytes($nextRIFFheaderID).') - skipping rest of file');
                            break 2;

                    }

                }
                if ($RIFFsubtype == 'WAVE') {
                    $thisfile_riff_WAVE = &$thisfile_riff['WAVE'];
                }
                break;

            default:
                

        //$headerstring = $this->fread(1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame         $headerstring = $this->fread(226); // LAME header at offset 36 + 190 bytes of Xing/LAME data
        // MP3 audio frame structure:         // $aa $aa $aa $aa [$bb $bb] $cc...         // where $aa..$aa is the four-byte mpeg-audio header (below)         // $bb $bb is the optional 2-byte CRC         // and $cc... is the audio data
        $head4 = substr($headerstring, 0, 4);
        $head4_key = getid3_lib::PrintHexBytes($head4, true, false, false);
        static $MPEGaudioHeaderDecodeCache = array();
        if (isset($MPEGaudioHeaderDecodeCache[$head4_key])) {
            $MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4_key];
        } else {
            $MPEGheaderRawArray = self::MPEGaudioHeaderDecode($head4);
            $MPEGaudioHeaderDecodeCache[$head4_key] = $MPEGheaderRawArray;
        }

        static $MPEGaudioHeaderValidCache = array();
        if (!isset($MPEGaudioHeaderValidCache[$head4_key])) { // Not in cache             //$MPEGaudioHeaderValidCache[$head4_key] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1)
Home | Imprint | This part of the site doesn't use cookies.