getID3 example

$info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($thisfile_audio['bitrate'] / 8);
                }
                break;

            case 'CDXA':
                $info['fileformat'] = 'vcd'; // Asume Video CD                 $info['mime_type']  = 'video/mpeg';

                if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) {
                    getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, true);

                    $getid3_temp = new getID3();
                    $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize']$this->getid3->fp);
                    $getid3_mpeg = new getid3_mpeg($getid3_temp);
                    $getid3_mpeg->Analyze();
                    if (empty($getid3_temp->info['error'])) {
                        $info['audio']   = $getid3_temp->info['audio'];
                        $info['video']   = $getid3_temp->info['video'];
                        $info['mpeg']    = $getid3_temp->info['mpeg'];
                        $info['warning'] = $getid3_temp->info['warning'];
                    }
                    unset($getid3_temp$getid3_mpeg);
                }
                
                            if (substr($atom_data$mdat_offset, 12) == "\x00\x00\x00\x0C\x65\x6E\x63\x64\x00\x00\x01\x00") { // UTF-8                                 $mdat_offset += 12;
                            }
                    }

                    if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {

                        $info['avdataoffset'] = $atom_structure['offset'] + 8;                       // $info['quicktime'][$atomname]['offset'] + 8;                         $OldAVDataEnd         = $info['avdataend'];
                        $info['avdataend']    = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
                        $getid3_temp = new getID3();
                        $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize']$this->getid3->fp);
                        $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
                        $getid3_temp->info['avdataend']    = $info['avdataend'];
                        $getid3_mp3 = new getid3_mp3($getid3_temp);
                        if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) {
                            $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
                            if (!empty($getid3_temp->info['warning'])) {
                                foreach ($getid3_temp->info['warning'] as $value) {
                                    $this->warning($value);
                                }
                            }
                            
case 'A_MPEG/L2':
                            case 'A_FLAC':
                                $module_dataformat = ($track_info['dataformat'] == 'mp2' ? 'mp3' : ($track_info['dataformat'] == 'eac3' ? 'ac3' : $track_info['dataformat']));
                                getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.$module_dataformat.'.php', __FILE__, true);

                                if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) {
                                    $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set');
                                    break;
                                }

                                // create temp instance                                 $getid3_temp = new getID3();
                                if ($track_info['dataformat'] != 'flac') {
                                    $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize']$this->getid3->fp);
                                }
                                $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
                                if ($track_info['dataformat'][0] == 'm' || $track_info['dataformat'] == 'flac') {
                                    $getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length'];
                                }

                                // analyze                                 $class = 'getid3_'.$module_dataformat;
                                $header_data_key = $track_info['dataformat'][0] == 'm' ? 'mpeg' : $track_info['dataformat'];
                                
$metadata = array();

    if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
        define( 'GETID3_TEMP_DIR', get_temp_dir() );
    }

    if ( ! class_exists( 'getID3', false ) ) {
        require ABSPATH . WPINC . '/ID3/getid3.php';
    }

    $id3 = new getID3();
    // Required to get the `created_timestamp` value.     $id3->options_audiovideo_quicktime_ReturnAtomData = true; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
    $data = $id3->analyze( $file );

    if ( isset( $data['video']['lossless'] ) ) {
        $metadata['lossless'] = $data['video']['lossless'];
    }

    if ( ! empty( $data['video']['bitrate'] ) ) {
        $metadata['bitrate'] = (int) $data['video']['bitrate'];
    }
$GetDataImageSize['width'] = $GetDataImageSize[1];
            return $GetDataImageSize;
        }
        static $tempdir = '';
        if (empty($tempdir)) {
            if (function_exists('sys_get_temp_dir')) {
                $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52             }

            // yes this is ugly, feel free to suggest a better way             if (include_once(dirname(__FILE__).'/getid3.php')) {
                $getid3_temp = new getID3();
                if ($getid3_temp_tempdir = $getid3_temp->tempdir) {
                    $tempdir = $getid3_temp_tempdir;
                }
                unset($getid3_temp$getid3_temp_tempdir);
            }
        }
        $GetDataImageSize = false;
        if ($tempfilename = tempnam($tempdir, 'gI3')) {
            if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
                fwrite($tmp$imgData);
                fclose($tmp);
                


        if (isset($lyrics3offset) && isset($lyrics3version) && isset($lyrics3size)) {
            $info['avdataend'] = $lyrics3offset;
            $this->getLyrics3Data($lyrics3offset$lyrics3version$lyrics3size);

            if (!isset($info['ape'])) {
                if (isset($info['lyrics3']['tag_offset_start'])) {
                    $GETID3_ERRORARRAY = &$info['warning'];
                    getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true);
                    $getid3_temp = new getID3();
                    $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize']$this->getid3->fp);
                    $getid3_apetag = new getid3_apetag($getid3_temp);
                    $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
                    $getid3_apetag->Analyze();
                    if (!empty($getid3_temp->info['ape'])) {
                        $info['ape'] = $getid3_temp->info['ape'];
                    }
                    if (!empty($getid3_temp->info['replay_gain'])) {
                        $info['replay_gain'] = $getid3_temp->info['replay_gain'];
                    }
                    unset($getid3_temp$getid3_apetag);
                }
Home | Imprint | This part of the site doesn't use cookies.