WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

getid3_mp3::GuessEncoderOptions() public WP 1.0

Это метод класса: getid3_mp3{}

Хуков нет.

Возвращает

Строку.

Использование

$getid3_mp3 = new getid3_mp3();
$getid3_mp3->GuessEncoderOptions();

Код getid3_mp3::GuessEncoderOptions() WP 5.5.1

wp-includes/ID3/module.audio.mp3.php
<?php
public function GuessEncoderOptions() {
	// shortcuts
	$info = &$this->getid3->info;
	$thisfile_mpeg_audio = array();
	$thisfile_mpeg_audio_lame = array();
	if (!empty($info['mpeg']['audio'])) {
		$thisfile_mpeg_audio = &$info['mpeg']['audio'];
		if (!empty($thisfile_mpeg_audio['LAME'])) {
			$thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME'];
		}
	}

	$encoder_options = '';
	static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256);

	if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) {

		$encoder_options = 'VBR q'.$thisfile_mpeg_audio['VBR_quality'];

	} elseif (!empty($thisfile_mpeg_audio_lame['preset_used']) && isset($thisfile_mpeg_audio_lame['preset_used_id']) && (!in_array($thisfile_mpeg_audio_lame['preset_used_id'], $NamedPresetBitrates))) {

		$encoder_options = $thisfile_mpeg_audio_lame['preset_used'];

	} elseif (!empty($thisfile_mpeg_audio_lame['vbr_quality'])) {

		static $KnownEncoderValues = array();
		if (empty($KnownEncoderValues)) {

			//$KnownEncoderValues[abrbitrate_minbitrate][vbr_quality][raw_vbr_method][raw_noise_shaping][raw_stereo_mode][ath_type][lowpass_frequency] = 'preset name';
			$KnownEncoderValues[0xFF][58][1][1][3][2][20500] = '--alt-preset insane';        // 3.90,   3.90.1, 3.92
			$KnownEncoderValues[0xFF][58][1][1][3][2][20600] = '--alt-preset insane';        // 3.90.2, 3.90.3, 3.91
			$KnownEncoderValues[0xFF][57][1][1][3][4][20500] = '--alt-preset insane';        // 3.94,   3.95
			$KnownEncoderValues['**'][78][3][2][3][2][19500] = '--alt-preset extreme';       // 3.90,   3.90.1, 3.92
			$KnownEncoderValues['**'][78][3][2][3][2][19600] = '--alt-preset extreme';       // 3.90.2, 3.91
			$KnownEncoderValues['**'][78][3][1][3][2][19600] = '--alt-preset extreme';       // 3.90.3
			$KnownEncoderValues['**'][78][4][2][3][2][19500] = '--alt-preset fast extreme';  // 3.90,   3.90.1, 3.92
			$KnownEncoderValues['**'][78][4][2][3][2][19600] = '--alt-preset fast extreme';  // 3.90.2, 3.90.3, 3.91
			$KnownEncoderValues['**'][78][3][2][3][4][19000] = '--alt-preset standard';      // 3.90,   3.90.1, 3.90.2, 3.91, 3.92
			$KnownEncoderValues['**'][78][3][1][3][4][19000] = '--alt-preset standard';      // 3.90.3
			$KnownEncoderValues['**'][78][4][2][3][4][19000] = '--alt-preset fast standard'; // 3.90,   3.90.1, 3.90.2, 3.91, 3.92
			$KnownEncoderValues['**'][78][4][1][3][4][19000] = '--alt-preset fast standard'; // 3.90.3
			$KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix';                    // 3.90,   3.90.1, 3.92
			$KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix';                    // 3.90.2, 3.90.3, 3.91
			$KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix';                    // 3.94,   3.95
			$KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium';        // 3.90.3
			$KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium';   // 3.90.3

			$KnownEncoderValues[0xFF][99][1][1][1][2][0]     = '--preset studio';            // 3.90,   3.90.1, 3.90.2, 3.91, 3.92
			$KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio';            // 3.90.3, 3.93.1
			$KnownEncoderValues[0xFF][58][2][1][3][2][20500] = '--preset studio';            // 3.93
			$KnownEncoderValues[0xFF][57][2][1][3][4][20500] = '--preset studio';            // 3.94,   3.95
			$KnownEncoderValues[0xC0][88][1][1][1][2][0]     = '--preset cd';                // 3.90,   3.90.1, 3.90.2,   3.91, 3.92
			$KnownEncoderValues[0xC0][58][2][2][3][2][19600] = '--preset cd';                // 3.90.3, 3.93.1
			$KnownEncoderValues[0xC0][58][2][2][3][2][19500] = '--preset cd';                // 3.93
			$KnownEncoderValues[0xC0][57][2][1][3][4][19500] = '--preset cd';                // 3.94,   3.95
			$KnownEncoderValues[0xA0][78][1][1][3][2][18000] = '--preset hifi';              // 3.90,   3.90.1, 3.90.2,   3.91, 3.92
			$KnownEncoderValues[0xA0][58][2][2][3][2][18000] = '--preset hifi';              // 3.90.3, 3.93,   3.93.1
			$KnownEncoderValues[0xA0][57][2][1][3][4][18000] = '--preset hifi';              // 3.94,   3.95
			$KnownEncoderValues[0x80][67][1][1][3][2][18000] = '--preset tape';              // 3.90,   3.90.1, 3.90.2,   3.91, 3.92
			$KnownEncoderValues[0x80][67][1][1][3][2][15000] = '--preset radio';             // 3.90,   3.90.1, 3.90.2,   3.91, 3.92
			$KnownEncoderValues[0x70][67][1][1][3][2][15000] = '--preset fm';                // 3.90,   3.90.1, 3.90.2,   3.91, 3.92
			$KnownEncoderValues[0x70][58][2][2][3][2][16000] = '--preset tape/radio/fm';     // 3.90.3, 3.93,   3.93.1
			$KnownEncoderValues[0x70][57][2][1][3][4][16000] = '--preset tape/radio/fm';     // 3.94,   3.95
			$KnownEncoderValues[0x38][58][2][2][0][2][10000] = '--preset voice';             // 3.90.3, 3.93,   3.93.1
			$KnownEncoderValues[0x38][57][2][1][0][4][15000] = '--preset voice';             // 3.94,   3.95
			$KnownEncoderValues[0x38][57][2][1][0][4][16000] = '--preset voice';             // 3.94a14
			$KnownEncoderValues[0x28][65][1][1][0][2][7500]  = '--preset mw-us';             // 3.90,   3.90.1, 3.92
			$KnownEncoderValues[0x28][65][1][1][0][2][7600]  = '--preset mw-us';             // 3.90.2, 3.91
			$KnownEncoderValues[0x28][58][2][2][0][2][7000]  = '--preset mw-us';             // 3.90.3, 3.93,   3.93.1
			$KnownEncoderValues[0x28][57][2][1][0][4][10500] = '--preset mw-us';             // 3.94,   3.95
			$KnownEncoderValues[0x28][57][2][1][0][4][11200] = '--preset mw-us';             // 3.94a14
			$KnownEncoderValues[0x28][57][2][1][0][4][8800]  = '--preset mw-us';             // 3.94a15
			$KnownEncoderValues[0x18][58][2][2][0][2][4000]  = '--preset phon+/lw/mw-eu/sw'; // 3.90.3, 3.93.1
			$KnownEncoderValues[0x18][58][2][2][0][2][3900]  = '--preset phon+/lw/mw-eu/sw'; // 3.93
			$KnownEncoderValues[0x18][57][2][1][0][4][5900]  = '--preset phon+/lw/mw-eu/sw'; // 3.94,   3.95
			$KnownEncoderValues[0x18][57][2][1][0][4][6200]  = '--preset phon+/lw/mw-eu/sw'; // 3.94a14
			$KnownEncoderValues[0x18][57][2][1][0][4][3200]  = '--preset phon+/lw/mw-eu/sw'; // 3.94a15
			$KnownEncoderValues[0x10][58][2][2][0][2][3800]  = '--preset phone';             // 3.90.3, 3.93.1
			$KnownEncoderValues[0x10][58][2][2][0][2][3700]  = '--preset phone';             // 3.93
			$KnownEncoderValues[0x10][57][2][1][0][4][5600]  = '--preset phone';             // 3.94,   3.95
		}

		if (isset($KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) {

			$encoder_options = $KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']];

		} elseif (isset($KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) {

			$encoder_options = $KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']];

		} elseif ($info['audio']['bitrate_mode'] == 'vbr') {

			// http://gabriel.mp3-tech.org/mp3infotag.html
			// int    Quality = (100 - 10 * gfp->VBR_q - gfp->quality)h


			$LAME_V_value = 10 - ceil($thisfile_mpeg_audio_lame['vbr_quality'] / 10);
			$LAME_q_value = 100 - $thisfile_mpeg_audio_lame['vbr_quality'] - ($LAME_V_value * 10);
			$encoder_options = '-V'.$LAME_V_value.' -q'.$LAME_q_value;

		} elseif ($info['audio']['bitrate_mode'] == 'cbr') {

			$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);

		} else {

			$encoder_options = strtoupper($info['audio']['bitrate_mode']);

		}

	} elseif (!empty($thisfile_mpeg_audio_lame['bitrate_abr'])) {

		$encoder_options = 'ABR'.$thisfile_mpeg_audio_lame['bitrate_abr'];

	} elseif (!empty($info['audio']['bitrate'])) {

		if ($info['audio']['bitrate_mode'] == 'cbr') {
			$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
		} else {
			$encoder_options = strtoupper($info['audio']['bitrate_mode']);
		}

	}
	if (!empty($thisfile_mpeg_audio_lame['bitrate_min'])) {
		$encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min'];
	}

	if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) {
		$encoder_options .= ' --nogap';
	}

	if (!empty($thisfile_mpeg_audio_lame['lowpass_frequency'])) {
		$ExplodedOptions = explode(' ', $encoder_options, 4);
		if ($ExplodedOptions[0] == '--r3mix') {
			$ExplodedOptions[1] = 'r3mix';
		}
		switch ($ExplodedOptions[0]) {
			case '--preset':
			case '--alt-preset':
			case '--r3mix':
				if ($ExplodedOptions[1] == 'fast') {
					$ExplodedOptions[1] .= ' '.$ExplodedOptions[2];
				}
				switch ($ExplodedOptions[1]) {
					case 'portable':
					case 'medium':
					case 'standard':
					case 'extreme':
					case 'insane':
					case 'fast portable':
					case 'fast medium':
					case 'fast standard':
					case 'fast extreme':
					case 'fast insane':
					case 'r3mix':
						static $ExpectedLowpass = array(
								'insane|20500'        => 20500,
								'insane|20600'        => 20600,  // 3.90.2, 3.90.3, 3.91
								'medium|18000'        => 18000,
								'fast medium|18000'   => 18000,
								'extreme|19500'       => 19500,  // 3.90,   3.90.1, 3.92, 3.95
								'extreme|19600'       => 19600,  // 3.90.2, 3.90.3, 3.91, 3.93.1
								'fast extreme|19500'  => 19500,  // 3.90,   3.90.1, 3.92, 3.95
								'fast extreme|19600'  => 19600,  // 3.90.2, 3.90.3, 3.91, 3.93.1
								'standard|19000'      => 19000,
								'fast standard|19000' => 19000,
								'r3mix|19500'         => 19500,  // 3.90,   3.90.1, 3.92
								'r3mix|19600'         => 19600,  // 3.90.2, 3.90.3, 3.91
								'r3mix|18000'         => 18000,  // 3.94,   3.95
							);
						if (!isset($ExpectedLowpass[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio_lame['lowpass_frequency']]) && ($thisfile_mpeg_audio_lame['lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame['lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio['sample_rate'] / 2000))) {
							$encoder_options .= ' --lowpass '.$thisfile_mpeg_audio_lame['lowpass_frequency'];
						}
						break;

					default:
						break;
				}
				break;
		}
	}

	if (isset($thisfile_mpeg_audio_lame['raw']['source_sample_freq'])) {
		if (($thisfile_mpeg_audio['sample_rate'] == 44100) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 1)) {
			$encoder_options .= ' --resample 44100';
		} elseif (($thisfile_mpeg_audio['sample_rate'] == 48000) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 2)) {
			$encoder_options .= ' --resample 48000';
		} elseif ($thisfile_mpeg_audio['sample_rate'] < 44100) {
			switch ($thisfile_mpeg_audio_lame['raw']['source_sample_freq']) {
				case 0: // <= 32000
					// may or may not be same as source frequency - ignore
					break;
				case 1: // 44100
				case 2: // 48000
				case 3: // 48000+
					$ExplodedOptions = explode(' ', $encoder_options, 4);
					switch ($ExplodedOptions[0]) {
						case '--preset':
						case '--alt-preset':
							switch ($ExplodedOptions[1]) {
								case 'fast':
								case 'portable':
								case 'medium':
								case 'standard':
								case 'extreme':
								case 'insane':
									$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
									break;

								default:
									static $ExpectedResampledRate = array(
											'phon+/lw/mw-eu/sw|16000' => 16000,
											'mw-us|24000'             => 24000, // 3.95
											'mw-us|32000'             => 32000, // 3.93
											'mw-us|16000'             => 16000, // 3.92
											'phone|16000'             => 16000,
											'phone|11025'             => 11025, // 3.94a15
											'radio|32000'             => 32000, // 3.94a15
											'fm/radio|32000'          => 32000, // 3.92
											'fm|32000'                => 32000, // 3.90
											'voice|32000'             => 32000);
									if (!isset($ExpectedResampledRate[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio['sample_rate']])) {
										$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
									}
									break;
							}
							break;

						case '--r3mix':
						default:
							$encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate'];
							break;
					}
					break;
			}
		}
	}
	if (empty($encoder_options) && !empty($info['audio']['bitrate']) && !empty($info['audio']['bitrate_mode'])) {
		//$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000);
		$encoder_options = strtoupper($info['audio']['bitrate_mode']);
	}

	return $encoder_options;
}