Edit File by line
/home/barbar84/public_h.../wp-inclu.../ID3
File: module.audio-video.flv.php
<?php
[0] Fix | Delete
/////////////////////////////////////////////////////////////////
[1] Fix | Delete
/// getID3() by James Heinrich <info@getid3.org> //
[2] Fix | Delete
// available at https://github.com/JamesHeinrich/getID3 //
[3] Fix | Delete
// or https://www.getid3.org //
[4] Fix | Delete
// or http://getid3.sourceforge.net //
[5] Fix | Delete
// see readme.txt for more details //
[6] Fix | Delete
/////////////////////////////////////////////////////////////////
[7] Fix | Delete
// //
[8] Fix | Delete
// module.audio-video.flv.php //
[9] Fix | Delete
// module for analyzing Shockwave Flash Video files //
[10] Fix | Delete
// dependencies: NONE //
[11] Fix | Delete
// //
[12] Fix | Delete
/////////////////////////////////////////////////////////////////
[13] Fix | Delete
// //
[14] Fix | Delete
// FLV module by Seth Kaufman <sethØwhirl-i-gig*com> //
[15] Fix | Delete
// //
[16] Fix | Delete
// * version 0.1 (26 June 2005) //
[17] Fix | Delete
// //
[18] Fix | Delete
// * version 0.1.1 (15 July 2005) //
[19] Fix | Delete
// minor modifications by James Heinrich <info@getid3.org> //
[20] Fix | Delete
// //
[21] Fix | Delete
// * version 0.2 (22 February 2006) //
[22] Fix | Delete
// Support for On2 VP6 codec and meta information //
[23] Fix | Delete
// by Steve Webster <steve.websterØfeaturecreep*com> //
[24] Fix | Delete
// //
[25] Fix | Delete
// * version 0.3 (15 June 2006) //
[26] Fix | Delete
// Modified to not read entire file into memory //
[27] Fix | Delete
// by James Heinrich <info@getid3.org> //
[28] Fix | Delete
// //
[29] Fix | Delete
// * version 0.4 (07 December 2007) //
[30] Fix | Delete
// Bugfixes for incorrectly parsed FLV dimensions //
[31] Fix | Delete
// and incorrect parsing of onMetaTag //
[32] Fix | Delete
// by Evgeny Moysevich <moysevichØgmail*com> //
[33] Fix | Delete
// //
[34] Fix | Delete
// * version 0.5 (21 May 2009) //
[35] Fix | Delete
// Fixed parsing of audio tags and added additional codec //
[36] Fix | Delete
// details. The duration is now read from onMetaTag (if //
[37] Fix | Delete
// exists), rather than parsing whole file //
[38] Fix | Delete
// by Nigel Barnes <ngbarnesØhotmail*com> //
[39] Fix | Delete
// //
[40] Fix | Delete
// * version 0.6 (24 May 2009) //
[41] Fix | Delete
// Better parsing of files with h264 video //
[42] Fix | Delete
// by Evgeny Moysevich <moysevichØgmail*com> //
[43] Fix | Delete
// //
[44] Fix | Delete
// * version 0.6.1 (30 May 2011) //
[45] Fix | Delete
// prevent infinite loops in expGolombUe() //
[46] Fix | Delete
// //
[47] Fix | Delete
// * version 0.7.0 (16 Jul 2013) //
[48] Fix | Delete
// handle GETID3_FLV_VIDEO_VP6FLV_ALPHA //
[49] Fix | Delete
// improved AVCSequenceParameterSetReader::readData() //
[50] Fix | Delete
// by Xander Schouwerwou <schouwerwouØgmail*com> //
[51] Fix | Delete
// ///
[52] Fix | Delete
/////////////////////////////////////////////////////////////////
[53] Fix | Delete
[54] Fix | Delete
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
[55] Fix | Delete
exit;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
define('GETID3_FLV_TAG_AUDIO', 8);
[59] Fix | Delete
define('GETID3_FLV_TAG_VIDEO', 9);
[60] Fix | Delete
define('GETID3_FLV_TAG_META', 18);
[61] Fix | Delete
[62] Fix | Delete
define('GETID3_FLV_VIDEO_H263', 2);
[63] Fix | Delete
define('GETID3_FLV_VIDEO_SCREEN', 3);
[64] Fix | Delete
define('GETID3_FLV_VIDEO_VP6FLV', 4);
[65] Fix | Delete
define('GETID3_FLV_VIDEO_VP6FLV_ALPHA', 5);
[66] Fix | Delete
define('GETID3_FLV_VIDEO_SCREENV2', 6);
[67] Fix | Delete
define('GETID3_FLV_VIDEO_H264', 7);
[68] Fix | Delete
[69] Fix | Delete
define('H264_AVC_SEQUENCE_HEADER', 0);
[70] Fix | Delete
define('H264_PROFILE_BASELINE', 66);
[71] Fix | Delete
define('H264_PROFILE_MAIN', 77);
[72] Fix | Delete
define('H264_PROFILE_EXTENDED', 88);
[73] Fix | Delete
define('H264_PROFILE_HIGH', 100);
[74] Fix | Delete
define('H264_PROFILE_HIGH10', 110);
[75] Fix | Delete
define('H264_PROFILE_HIGH422', 122);
[76] Fix | Delete
define('H264_PROFILE_HIGH444', 144);
[77] Fix | Delete
define('H264_PROFILE_HIGH444_PREDICTIVE', 244);
[78] Fix | Delete
[79] Fix | Delete
class getid3_flv extends getid3_handler
[80] Fix | Delete
{
[81] Fix | Delete
const magic = 'FLV';
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Break out of the loop if too many frames have been scanned; only scan this
[85] Fix | Delete
* many if meta frame does not contain useful duration.
[86] Fix | Delete
*
[87] Fix | Delete
* @var int
[88] Fix | Delete
*/
[89] Fix | Delete
public $max_frames = 100000;
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* @return bool
[93] Fix | Delete
*/
[94] Fix | Delete
public function Analyze() {
[95] Fix | Delete
$info = &$this->getid3->info;
[96] Fix | Delete
[97] Fix | Delete
$this->fseek($info['avdataoffset']);
[98] Fix | Delete
[99] Fix | Delete
$FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
[100] Fix | Delete
$FLVheader = $this->fread(5);
[101] Fix | Delete
[102] Fix | Delete
$info['fileformat'] = 'flv';
[103] Fix | Delete
$info['flv']['header']['signature'] = substr($FLVheader, 0, 3);
[104] Fix | Delete
$info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
[105] Fix | Delete
$TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
[106] Fix | Delete
[107] Fix | Delete
if ($info['flv']['header']['signature'] != self::magic) {
[108] Fix | Delete
$this->error('Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"');
[109] Fix | Delete
unset($info['flv'], $info['fileformat']);
[110] Fix | Delete
return false;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
$info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
[114] Fix | Delete
$info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
[115] Fix | Delete
[116] Fix | Delete
$FrameSizeDataLength = getid3_lib::BigEndian2Int($this->fread(4));
[117] Fix | Delete
$FLVheaderFrameLength = 9;
[118] Fix | Delete
if ($FrameSizeDataLength > $FLVheaderFrameLength) {
[119] Fix | Delete
$this->fseek($FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
[120] Fix | Delete
}
[121] Fix | Delete
$Duration = 0;
[122] Fix | Delete
$found_video = false;
[123] Fix | Delete
$found_audio = false;
[124] Fix | Delete
$found_meta = false;
[125] Fix | Delete
$found_valid_meta_playtime = false;
[126] Fix | Delete
$tagParseCount = 0;
[127] Fix | Delete
$info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0);
[128] Fix | Delete
$flv_framecount = &$info['flv']['framecount'];
[129] Fix | Delete
while ((($this->ftell() + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
[130] Fix | Delete
$ThisTagHeader = $this->fread(16);
[131] Fix | Delete
[132] Fix | Delete
$PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
[133] Fix | Delete
$TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
[134] Fix | Delete
$DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
[135] Fix | Delete
$Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
[136] Fix | Delete
$LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
[137] Fix | Delete
$NextOffset = $this->ftell() - 1 + $DataLength;
[138] Fix | Delete
if ($Timestamp > $Duration) {
[139] Fix | Delete
$Duration = $Timestamp;
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
$flv_framecount['total']++;
[143] Fix | Delete
switch ($TagType) {
[144] Fix | Delete
case GETID3_FLV_TAG_AUDIO:
[145] Fix | Delete
$flv_framecount['audio']++;
[146] Fix | Delete
if (!$found_audio) {
[147] Fix | Delete
$found_audio = true;
[148] Fix | Delete
$info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
[149] Fix | Delete
$info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03;
[150] Fix | Delete
$info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
[151] Fix | Delete
$info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01;
[152] Fix | Delete
}
[153] Fix | Delete
break;
[154] Fix | Delete
[155] Fix | Delete
case GETID3_FLV_TAG_VIDEO:
[156] Fix | Delete
$flv_framecount['video']++;
[157] Fix | Delete
if (!$found_video) {
[158] Fix | Delete
$found_video = true;
[159] Fix | Delete
$info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
[160] Fix | Delete
[161] Fix | Delete
$FLVvideoHeader = $this->fread(11);
[162] Fix | Delete
[163] Fix | Delete
if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
[164] Fix | Delete
// this code block contributed by: moysevichØgmail*com
[165] Fix | Delete
[166] Fix | Delete
$AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1));
[167] Fix | Delete
if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) {
[168] Fix | Delete
// read AVCDecoderConfigurationRecord
[169] Fix | Delete
$configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1));
[170] Fix | Delete
$AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1));
[171] Fix | Delete
$profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1));
[172] Fix | Delete
$lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1));
[173] Fix | Delete
$numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1));
[174] Fix | Delete
[175] Fix | Delete
if (($numOfSequenceParameterSets & 0x1F) != 0) {
[176] Fix | Delete
// there is at least one SequenceParameterSet
[177] Fix | Delete
// read size of the first SequenceParameterSet
[178] Fix | Delete
//$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));
[179] Fix | Delete
$spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
[180] Fix | Delete
// read the first SequenceParameterSet
[181] Fix | Delete
$sps = $this->fread($spsSize);
[182] Fix | Delete
if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red
[183] Fix | Delete
$spsReader = new AVCSequenceParameterSetReader($sps);
[184] Fix | Delete
$spsReader->readData();
[185] Fix | Delete
$info['video']['resolution_x'] = $spsReader->getWidth();
[186] Fix | Delete
$info['video']['resolution_y'] = $spsReader->getHeight();
[187] Fix | Delete
}
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
// end: moysevichØgmail*com
[191] Fix | Delete
[192] Fix | Delete
} elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) {
[193] Fix | Delete
[194] Fix | Delete
$PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
[195] Fix | Delete
$PictureSizeType = $PictureSizeType & 0x0007;
[196] Fix | Delete
$info['flv']['header']['videoSizeType'] = $PictureSizeType;
[197] Fix | Delete
switch ($PictureSizeType) {
[198] Fix | Delete
case 0:
[199] Fix | Delete
//$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
[200] Fix | Delete
//$PictureSizeEnc <<= 1;
[201] Fix | Delete
//$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
[202] Fix | Delete
//$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
[203] Fix | Delete
//$PictureSizeEnc <<= 1;
[204] Fix | Delete
//$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
[205] Fix | Delete
[206] Fix | Delete
$PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2)) >> 7;
[207] Fix | Delete
$PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)) >> 7;
[208] Fix | Delete
$info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
[209] Fix | Delete
$info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
[210] Fix | Delete
break;
[211] Fix | Delete
[212] Fix | Delete
case 1:
[213] Fix | Delete
$PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3)) >> 7;
[214] Fix | Delete
$PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3)) >> 7;
[215] Fix | Delete
$info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
[216] Fix | Delete
$info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
[217] Fix | Delete
break;
[218] Fix | Delete
[219] Fix | Delete
case 2:
[220] Fix | Delete
$info['video']['resolution_x'] = 352;
[221] Fix | Delete
$info['video']['resolution_y'] = 288;
[222] Fix | Delete
break;
[223] Fix | Delete
[224] Fix | Delete
case 3:
[225] Fix | Delete
$info['video']['resolution_x'] = 176;
[226] Fix | Delete
$info['video']['resolution_y'] = 144;
[227] Fix | Delete
break;
[228] Fix | Delete
[229] Fix | Delete
case 4:
[230] Fix | Delete
$info['video']['resolution_x'] = 128;
[231] Fix | Delete
$info['video']['resolution_y'] = 96;
[232] Fix | Delete
break;
[233] Fix | Delete
[234] Fix | Delete
case 5:
[235] Fix | Delete
$info['video']['resolution_x'] = 320;
[236] Fix | Delete
$info['video']['resolution_y'] = 240;
[237] Fix | Delete
break;
[238] Fix | Delete
[239] Fix | Delete
case 6:
[240] Fix | Delete
$info['video']['resolution_x'] = 160;
[241] Fix | Delete
$info['video']['resolution_y'] = 120;
[242] Fix | Delete
break;
[243] Fix | Delete
[244] Fix | Delete
default:
[245] Fix | Delete
$info['video']['resolution_x'] = 0;
[246] Fix | Delete
$info['video']['resolution_y'] = 0;
[247] Fix | Delete
break;
[248] Fix | Delete
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
} elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_VP6FLV_ALPHA) {
[252] Fix | Delete
[253] Fix | Delete
/* contributed by schouwerwouØgmail*com */
[254] Fix | Delete
if (!isset($info['video']['resolution_x'])) { // only when meta data isn't set
[255] Fix | Delete
$PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
[256] Fix | Delete
$PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 2));
[257] Fix | Delete
$info['video']['resolution_x'] = ($PictureSizeEnc['x'] & 0xFF) << 3;
[258] Fix | Delete
$info['video']['resolution_y'] = ($PictureSizeEnc['y'] & 0xFF) << 3;
[259] Fix | Delete
}
[260] Fix | Delete
/* end schouwerwouØgmail*com */
[261] Fix | Delete
[262] Fix | Delete
}
[263] Fix | Delete
if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) {
[264] Fix | Delete
$info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
break;
[268] Fix | Delete
[269] Fix | Delete
// Meta tag
[270] Fix | Delete
case GETID3_FLV_TAG_META:
[271] Fix | Delete
if (!$found_meta) {
[272] Fix | Delete
$found_meta = true;
[273] Fix | Delete
$this->fseek(-1, SEEK_CUR);
[274] Fix | Delete
$datachunk = $this->fread($DataLength);
[275] Fix | Delete
$AMFstream = new AMFStream($datachunk);
[276] Fix | Delete
$reader = new AMFReader($AMFstream);
[277] Fix | Delete
$eventName = $reader->readData();
[278] Fix | Delete
$info['flv']['meta'][$eventName] = $reader->readData();
[279] Fix | Delete
unset($reader);
[280] Fix | Delete
[281] Fix | Delete
$copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate');
[282] Fix | Delete
foreach ($copykeys as $sourcekey => $destkey) {
[283] Fix | Delete
if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
[284] Fix | Delete
switch ($sourcekey) {
[285] Fix | Delete
case 'width':
[286] Fix | Delete
case 'height':
[287] Fix | Delete
$info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
[288] Fix | Delete
break;
[289] Fix | Delete
case 'audiodatarate':
[290] Fix | Delete
$info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
[291] Fix | Delete
break;
[292] Fix | Delete
case 'videodatarate':
[293] Fix | Delete
case 'frame_rate':
[294] Fix | Delete
default:
[295] Fix | Delete
$info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
[296] Fix | Delete
break;
[297] Fix | Delete
}
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
[301] Fix | Delete
$found_valid_meta_playtime = true;
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
break;
[305] Fix | Delete
[306] Fix | Delete
default:
[307] Fix | Delete
// noop
[308] Fix | Delete
break;
[309] Fix | Delete
}
[310] Fix | Delete
$this->fseek($NextOffset);
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
$info['playtime_seconds'] = $Duration / 1000;
[314] Fix | Delete
if ($info['playtime_seconds'] > 0) {
[315] Fix | Delete
$info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
if ($info['flv']['header']['hasAudio']) {
[319] Fix | Delete
$info['audio']['codec'] = self::audioFormatLookup($info['flv']['audio']['audioFormat']);
[320] Fix | Delete
$info['audio']['sample_rate'] = self::audioRateLookup($info['flv']['audio']['audioRate']);
[321] Fix | Delete
$info['audio']['bits_per_sample'] = self::audioBitDepthLookup($info['flv']['audio']['audioSampleSize']);
[322] Fix | Delete
[323] Fix | Delete
$info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
[324] Fix | Delete
$info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
[325] Fix | Delete
$info['audio']['dataformat'] = 'flv';
[326] Fix | Delete
}
[327] Fix | Delete
if (!empty($info['flv']['header']['hasVideo'])) {
[328] Fix | Delete
$info['video']['codec'] = self::videoCodecLookup($info['flv']['video']['videoCodec']);
[329] Fix | Delete
$info['video']['dataformat'] = 'flv';
[330] Fix | Delete
$info['video']['lossless'] = false;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
// Set information from meta
[334] Fix | Delete
if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
[335] Fix | Delete
$info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
[336] Fix | Delete
$info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
[337] Fix | Delete
}
[338] Fix | Delete
if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
[339] Fix | Delete
$info['audio']['codec'] = self::audioFormatLookup($info['flv']['meta']['onMetaData']['audiocodecid']);
[340] Fix | Delete
}
[341] Fix | Delete
if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
[342] Fix | Delete
$info['video']['codec'] = self::videoCodecLookup($info['flv']['meta']['onMetaData']['videocodecid']);
[343] Fix | Delete
}
[344] Fix | Delete
return true;
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
/**
[348] Fix | Delete
* @param int $id
[349] Fix | Delete
*
[350] Fix | Delete
* @return string|false
[351] Fix | Delete
*/
[352] Fix | Delete
public static function audioFormatLookup($id) {
[353] Fix | Delete
static $lookup = array(
[354] Fix | Delete
0 => 'Linear PCM, platform endian',
[355] Fix | Delete
1 => 'ADPCM',
[356] Fix | Delete
2 => 'mp3',
[357] Fix | Delete
3 => 'Linear PCM, little endian',
[358] Fix | Delete
4 => 'Nellymoser 16kHz mono',
[359] Fix | Delete
5 => 'Nellymoser 8kHz mono',
[360] Fix | Delete
6 => 'Nellymoser',
[361] Fix | Delete
7 => 'G.711A-law logarithmic PCM',
[362] Fix | Delete
8 => 'G.711 mu-law logarithmic PCM',
[363] Fix | Delete
9 => 'reserved',
[364] Fix | Delete
10 => 'AAC',
[365] Fix | Delete
11 => 'Speex',
[366] Fix | Delete
12 => false, // unknown?
[367] Fix | Delete
13 => false, // unknown?
[368] Fix | Delete
14 => 'mp3 8kHz',
[369] Fix | Delete
15 => 'Device-specific sound',
[370] Fix | Delete
);
[371] Fix | Delete
return (isset($lookup[$id]) ? $lookup[$id] : false);
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
/**
[375] Fix | Delete
* @param int $id
[376] Fix | Delete
*
[377] Fix | Delete
* @return int|false
[378] Fix | Delete
*/
[379] Fix | Delete
public static function audioRateLookup($id) {
[380] Fix | Delete
static $lookup = array(
[381] Fix | Delete
0 => 5500,
[382] Fix | Delete
1 => 11025,
[383] Fix | Delete
2 => 22050,
[384] Fix | Delete
3 => 44100,
[385] Fix | Delete
);
[386] Fix | Delete
return (isset($lookup[$id]) ? $lookup[$id] : false);
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* @param int $id
[391] Fix | Delete
*
[392] Fix | Delete
* @return int|false
[393] Fix | Delete
*/
[394] Fix | Delete
public static function audioBitDepthLookup($id) {
[395] Fix | Delete
static $lookup = array(
[396] Fix | Delete
0 => 8,
[397] Fix | Delete
1 => 16,
[398] Fix | Delete
);
[399] Fix | Delete
return (isset($lookup[$id]) ? $lookup[$id] : false);
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
/**
[403] Fix | Delete
* @param int $id
[404] Fix | Delete
*
[405] Fix | Delete
* @return string|false
[406] Fix | Delete
*/
[407] Fix | Delete
public static function videoCodecLookup($id) {
[408] Fix | Delete
static $lookup = array(
[409] Fix | Delete
GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
[410] Fix | Delete
GETID3_FLV_VIDEO_SCREEN => 'Screen video',
[411] Fix | Delete
GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6',
[412] Fix | Delete
GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel',
[413] Fix | Delete
GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2',
[414] Fix | Delete
GETID3_FLV_VIDEO_H264 => 'Sorenson H.264',
[415] Fix | Delete
);
[416] Fix | Delete
return (isset($lookup[$id]) ? $lookup[$id] : false);
[417] Fix | Delete
}
[418] Fix | Delete
}
[419] Fix | Delete
[420] Fix | Delete
class AMFStream
[421] Fix | Delete
{
[422] Fix | Delete
/**
[423] Fix | Delete
* @var string
[424] Fix | Delete
*/
[425] Fix | Delete
public $bytes;
[426] Fix | Delete
[427] Fix | Delete
/**
[428] Fix | Delete
* @var int
[429] Fix | Delete
*/
[430] Fix | Delete
public $pos;
[431] Fix | Delete
[432] Fix | Delete
/**
[433] Fix | Delete
* @param string $bytes
[434] Fix | Delete
*/
[435] Fix | Delete
public function __construct(&$bytes) {
[436] Fix | Delete
$this->bytes =& $bytes;
[437] Fix | Delete
$this->pos = 0;
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
/**
[441] Fix | Delete
* @return int
[442] Fix | Delete
*/
[443] Fix | Delete
public function readByte() { // 8-bit
[444] Fix | Delete
return ord(substr($this->bytes, $this->pos++, 1));
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
/**
[448] Fix | Delete
* @return int
[449] Fix | Delete
*/
[450] Fix | Delete
public function readInt() { // 16-bit
[451] Fix | Delete
return ($this->readByte() << 8) + $this->readByte();
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
/**
[455] Fix | Delete
* @return int
[456] Fix | Delete
*/
[457] Fix | Delete
public function readLong() { // 32-bit
[458] Fix | Delete
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
/**
[462] Fix | Delete
* @return float|false
[463] Fix | Delete
*/
[464] Fix | Delete
public function readDouble() {
[465] Fix | Delete
return getid3_lib::BigEndian2Float($this->read(8));
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
/**
[469] Fix | Delete
* @return string
[470] Fix | Delete
*/
[471] Fix | Delete
public function readUTF() {
[472] Fix | Delete
$length = $this->readInt();
[473] Fix | Delete
return $this->read($length);
[474] Fix | Delete
}
[475] Fix | Delete
[476] Fix | Delete
/**
[477] Fix | Delete
* @return string
[478] Fix | Delete
*/
[479] Fix | Delete
public function readLongUTF() {
[480] Fix | Delete
$length = $this->readLong();
[481] Fix | Delete
return $this->read($length);
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
/**
[485] Fix | Delete
* @param int $length
[486] Fix | Delete
*
[487] Fix | Delete
* @return string
[488] Fix | Delete
*/
[489] Fix | Delete
public function read($length) {
[490] Fix | Delete
$val = substr($this->bytes, $this->pos, $length);
[491] Fix | Delete
$this->pos += $length;
[492] Fix | Delete
return $val;
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
/**
[496] Fix | Delete
* @return int
[497] Fix | Delete
*/
[498] Fix | Delete
public function peekByte() {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function