本文整理匯總了PHP中getid3_lib::PrintHexBytes方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::PrintHexBytes方法的具體用法?PHP getid3_lib::PrintHexBytes怎麽用?PHP getid3_lib::PrintHexBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::PrintHexBytes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$info['mpc']['header'] = array();
$thisfile_mpc_header =& $info['mpc']['header'];
$info['fileformat'] = 'mpc';
$info['audio']['dataformat'] = 'mpc';
$info['audio']['bitrate_mode'] = 'vbr';
$info['audio']['channels'] = 2;
// up to SV7 the format appears to have been hardcoded for stereo only
$info['audio']['lossless'] = false;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$MPCheaderData = fread($this->getid3->fp, 4);
$info['mpc']['header']['preamble'] = substr($MPCheaderData, 0, 4);
// should be 'MPCK' (SV8) or 'MP+' (SV7), otherwise possible stream data (SV4-SV6)
if (preg_match('#^MPCK#', $info['mpc']['header']['preamble'])) {
// this is SV8
return $this->ParseMPCsv8();
} elseif (preg_match('#^MP\\+#', $info['mpc']['header']['preamble'])) {
// this is SV7
return $this->ParseMPCsv7();
} elseif (preg_match('/^[\\x00\\x01\\x10\\x11\\x40\\x41\\x50\\x51\\x80\\x81\\x90\\x91\\xC0\\xC1\\xD0\\xD1][\\x20-37][\\x00\\x20\\x40\\x60\\x80\\xA0\\xC0\\xE0]/s', $MPCheaderData)) {
// this is SV4 - SV6, handle seperately
return $this->ParseMPCsv6();
} else {
$info['error'][] = 'Expecting "MP+" or "MPCK" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($MPCheaderData, 0, 4)) . '"';
unset($info['fileformat']);
unset($info['mpc']);
return false;
}
return false;
}
示例2: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$DSSheader = fread($this->getid3->fp, 1256);
if (!preg_match('#^(\\x02|\\x03)dss#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-03] 64 73 73" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
// shortcut
$info['dss'] = array();
$thisfile_dss =& $info['dss'];
$info['fileformat'] = 'dss';
$info['audio']['dataformat'] = 'dss';
$info['audio']['bitrate_mode'] = 'cbr';
//$thisfile_dss['encoding'] = 'ISO-8859-1';
$thisfile_dss['version'] = ord(substr($DSSheader, 0, 1));
$thisfile_dss['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$thisfile_dss['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
//$thisfile_dss['length'] = intval(substr($DSSheader, 62, 6)); // I thought time was in seconds, it's actually HHMMSS
$thisfile_dss['length'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
$thisfile_dss['priority'] = ord(substr($DSSheader, 793, 1));
$thisfile_dss['comments'] = trim(substr($DSSheader, 798, 100));
//$info['audio']['bits_per_sample'] = ?;
//$info['audio']['sample_rate'] = ?;
$info['audio']['channels'] = 1;
$info['playtime_seconds'] = $thisfile_dss['length'];
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例3: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$NSVheader = fread($this->getid3->fp, 4);
switch ($NSVheader) {
case 'NSVs':
if ($this->getNSVsHeaderFilepointer(0)) {
$info['fileformat'] = 'nsv';
$info['audio']['dataformat'] = 'nsv';
$info['video']['dataformat'] = 'nsv';
$info['audio']['lossless'] = false;
$info['video']['lossless'] = false;
}
break;
case 'NSVf':
if ($this->getNSVfHeaderFilepointer(0)) {
$info['fileformat'] = 'nsv';
$info['audio']['dataformat'] = 'nsv';
$info['video']['dataformat'] = 'nsv';
$info['audio']['lossless'] = false;
$info['video']['lossless'] = false;
$this->getNSVsHeaderFilepointer($info['nsv']['NSVf']['header_length']);
}
break;
default:
$info['error'][] = 'Expecting "NSVs" or "NSVf" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($NSVheader) . '"';
return false;
break;
}
if (!isset($info['nsv']['NSVf'])) {
$info['warning'][] = 'NSVf header not present - cannot calculate playtime or bitrate';
}
return true;
}
示例4: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$this->fseek($info['avdataoffset']);
$EXEheader = $this->fread(28);
$magic = 'MZ';
if (substr($EXEheader, 0, 2) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($EXEheader, 0, 2)) . '"';
return false;
}
$info['fileformat'] = 'exe';
$info['exe']['mz']['magic'] = 'MZ';
$info['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
$info['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
$info['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
$info['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
$info['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
$info['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
$info['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
$info['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
$info['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
$info['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
$info['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
$info['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
$info['exe']['mz']['byte_size'] = ($info['exe']['mz']['raw']['page_count'] - 1) * 512 + $info['exe']['mz']['raw']['last_page_size'];
$info['exe']['mz']['header_size'] = $info['exe']['mz']['raw']['header_paragraphs'] * 16;
$info['exe']['mz']['memory_minimum'] = $info['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
$info['exe']['mz']['memory_recommended'] = $info['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
$info['error'][] = 'EXE parsing not enabled in this version of getID3() [' . $this->getid3->version() . ']';
return false;
}
示例5: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$SZIPHeader = fread($this->getid3->fp, 6);
if (substr($SZIPHeader, 0, 4) != "SZ\n") {
$info['error'][] = 'Expecting "53 5A 0A 04" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)) . '"';
return false;
}
$info['fileformat'] = 'szip';
$info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
$info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
while (!feof($this->getid3->fp)) {
$NextBlockID = fread($this->getid3->fp, 2);
switch ($NextBlockID) {
case 'SZ':
// Note that szip files can be concatenated, this has the same effect as
// concatenating the files. this also means that global header blocks
// might be present between directory/data blocks.
fseek($this->getid3->fp, 4, SEEK_CUR);
break;
case 'BH':
$BHheaderbytes = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 3));
$BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
$BHheaderoffset = 0;
while (strpos($BHheaderdata, "", $BHheaderoffset) > 0) {
//filename as \0 terminated string (empty string indicates end)
//owner as \0 terminated string (empty is same as last file)
//group as \0 terminated string (empty is same as last file)
//3 byte filelength in this block
//2 byte access flags
//4 byte creation time (like in unix)
//4 byte modification time (like in unix)
//4 byte access time (like in unix)
$BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
$BHheaderoffset += strlen($BHdataArray['filename']) + 1;
$BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
$BHheaderoffset += strlen($BHdataArray['owner']) + 1;
$BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, ""));
$BHheaderoffset += strlen($BHdataArray['group']) + 1;
$BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3));
$BHheaderoffset += 3;
$BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2));
$BHheaderoffset += 2;
$BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$info['szip']['BH'][] = $BHdataArray;
}
break;
default:
break 2;
}
}
return true;
}
示例6: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$this->fseek($info['avdataoffset']);
$DSSheader = $this->fread(1540);
if (!preg_match('#^[\\x02-\\x06]ds[s2]#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-06] 64 73 [73|32]" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
$info['encoding'] = 'ISO-8859-1';
// not certain, but assumed
$info['dss'] = array();
$info['fileformat'] = 'dss';
$info['mime_type'] = 'audio/x-' . substr($DSSheader, 1, 3);
// "audio/x-dss" or "audio/x-ds2"
$info['audio']['dataformat'] = substr($DSSheader, 1, 3);
// "dss" or "ds2"
$info['audio']['bitrate_mode'] = 'cbr';
$info['dss']['version'] = ord(substr($DSSheader, 0, 1));
$info['dss']['hardware'] = trim(substr($DSSheader, 12, 16));
// identification string for hardware used to create the file, e.g. "DPM 9600", "DS2400"
$info['dss']['unknown1'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 28, 4));
// 32-37 = "FE FF FE FF F7 FF" in all the sample files I've seen
$info['dss']['date_create_unix'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$info['dss']['date_complete_unix'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
$info['dss']['playtime_sec'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
// approximate file playtime in HHMMSS
if ($info['dss']['version'] <= 3) {
$info['dss']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 512, 4));
// exact file playtime in milliseconds. Has also been observed at offset 530 in one sample file, with something else (unknown) at offset 512
$info['dss']['priority'] = ord(substr($DSSheader, 793, 1));
$info['dss']['comments'] = trim(substr($DSSheader, 798, 100));
$info['dss']['sample_rate_index'] = ord(substr($DSSheader, 1538, 1));
// this isn't certain, this may or may not be where the sample rate info is stored, but it seems consistent on my small selection of sample files
$info['audio']['sample_rate'] = $this->DSSsampleRateLookup($info['dss']['sample_rate_index']);
} else {
$this->getid3->warning('DSS above version 3 not fully supported in this version of getID3. Any additional documentation or format specifications would be welcome. This file is version ' . $info['dss']['version']);
}
$info['audio']['bits_per_sample'] = 16;
// maybe, maybe not -- most compressed audio formats don't have a fixed bits-per-sample value, but this is a reasonable approximation
$info['audio']['channels'] = 1;
if (!empty($info['dss']['playtime_ms']) && floor($info['dss']['playtime_ms'] / 1000) == $info['dss']['playtime_sec']) {
// *should* just be playtime_ms / 1000 but at least one sample file has playtime_ms at offset 530 instead of offset 512, so safety check
$info['playtime_seconds'] = $info['dss']['playtime_ms'] / 1000;
} else {
$info['playtime_seconds'] = $info['dss']['playtime_sec'];
if (!empty($info['dss']['playtime_ms'])) {
$this->getid3->warning('playtime_ms (' . number_format($info['dss']['playtime_ms'] / 1000, 3) . ') does not match playtime_sec (' . number_format($info['dss']['playtime_sec']) . ') - using playtime_sec value');
}
}
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例7: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$DOCFILEheader = fread($this->getid3->fp, 8);
$magic = "поЮ║╠А";
if (substr($DOCFILEheader, 0, 8) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at ' . $info['avdataoffset'] . ', found ' . getid3_lib::PrintHexBytes(substr($DOCFILEheader, 0, 8)) . ' instead.';
return false;
}
$info['fileformat'] = 'msoffice';
$info['error'][] = 'MS Office (.doc, .xls, etc) parsing not enabled in this version of getID3() [' . $this->getid3->version() . ']';
return false;
}
示例8: Analyze
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();
}
示例9: Analyze
function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$RKAUHeader = fread($this->getid3->fp, 20);
$magic = 'RKA';
if (substr($RKAUHeader, 0, 3) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($RKAUHeader, 0, 3)) . '"';
return false;
}
$info['fileformat'] = 'rkau';
$info['audio']['dataformat'] = 'rkau';
$info['audio']['bitrate_mode'] = 'vbr';
$info['rkau']['raw']['version'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 3, 1));
$info['rkau']['version'] = '1.' . str_pad($info['rkau']['raw']['version'] & 0xf, 2, '0', STR_PAD_LEFT);
if ($info['rkau']['version'] > 1.07 || $info['rkau']['version'] < 1.06) {
$info['error'][] = 'This version of getID3() [' . $this->getid3->version() . '] can only parse RKAU files v1.06 and 1.07 (this file is v' . $info['rkau']['version'] . ')';
unset($info['rkau']);
return false;
}
$info['rkau']['source_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 4, 4));
$info['rkau']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 8, 4));
$info['rkau']['channels'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 12, 1));
$info['rkau']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 13, 1));
$info['rkau']['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 14, 1));
$this->RKAUqualityLookup($info['rkau']);
$info['rkau']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 15, 1));
$info['rkau']['flags']['joint_stereo'] = (bool) (!($info['rkau']['raw']['flags'] & 0x1));
$info['rkau']['flags']['streaming'] = (bool) ($info['rkau']['raw']['flags'] & 0x2);
$info['rkau']['flags']['vrq_lossy_mode'] = (bool) ($info['rkau']['raw']['flags'] & 0x4);
if ($info['rkau']['flags']['streaming']) {
$info['avdataoffset'] += 20;
$info['rkau']['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 16, 4));
} else {
$info['avdataoffset'] += 16;
$info['rkau']['compressed_bytes'] = $info['avdataend'] - $info['avdataoffset'] - 1;
}
// Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
// sometimes it's more, sometimes less. No idea why(?)
$info['audio']['lossless'] = $info['rkau']['lossless'];
$info['audio']['channels'] = $info['rkau']['channels'];
$info['audio']['bits_per_sample'] = $info['rkau']['bits_per_sample'];
$info['audio']['sample_rate'] = $info['rkau']['sample_rate'];
$info['playtime_seconds'] = $info['rkau']['source_bytes'] / ($info['rkau']['sample_rate'] * $info['rkau']['channels'] * ($info['rkau']['bits_per_sample'] / 8));
$info['audio']['bitrate'] = $info['rkau']['compressed_bytes'] * 8 / $info['playtime_seconds'];
return true;
}
示例10: Analyze
function Analyze()
{
$info =& $this->getid3->info;
// http://flac.sourceforge.net/format.html
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$StreamMarker = fread($this->getid3->fp, 4);
$magic = 'fLaC';
if ($StreamMarker != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($StreamMarker) . '"';
return false;
}
$info['fileformat'] = 'flac';
$info['audio']['dataformat'] = 'flac';
$info['audio']['bitrate_mode'] = 'vbr';
$info['audio']['lossless'] = true;
return $this->FLACparseMETAdata();
}
示例11: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$this->fseek($info['avdataoffset']);
$AMRheader = $this->fread(6);
$magic = '#!AMR' . "\n";
if (substr($AMRheader, 0, 6) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($AMRheader, 0, 6)) . '"';
return false;
}
// shortcut
$info['amr'] = array();
$thisfile_amr =& $info['amr'];
$info['fileformat'] = 'amr';
$info['audio']['dataformat'] = 'amr';
$info['audio']['bitrate_mode'] = 'vbr';
// within a small predefined range: 4.75kbps to 12.2kbps
$info['audio']['bits_per_sample'] = 13;
// http://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec: "Sampling frequency 8 kHz/13-bit (160 samples for 20 ms frames), filtered to 200–3400 Hz"
$info['audio']['sample_rate'] = 8000;
// http://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec: "Sampling frequency 8 kHz/13-bit (160 samples for 20 ms frames), filtered to 200–3400 Hz"
$info['audio']['channels'] = 1;
$thisfile_amr['frame_mode_count'] = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0);
$buffer = '';
do {
if (strlen($buffer) < $this->getid3->fread_buffer_size() && !feof($this->getid3->fp)) {
$buffer .= $this->fread($this->getid3->fread_buffer_size() * 2);
}
$AMR_frame_header = ord(substr($buffer, 0, 1));
$codec_mode_request = ($AMR_frame_header & 0x78) >> 3;
// The 2nd bit through 5th bit (counting the most significant bit as the first bit) comprise the CMR (Codec Mode Request), values 0-7 being valid for AMR. The top bit of the CMR can actually be ignored, though it is used when AMR forms RTP payloads. The lower 3-bits of the header are reserved and are not used. Viewing the header from most significant bit to least significant bit, the encoding is XCCCCXXX, where Xs are reserved (typically 0) and the Cs are the CMR.
if ($codec_mode_request > 7) {
$info['error'][] = '';
break;
}
$thisfile_amr['frame_mode_count'][$codec_mode_request]++;
$buffer = substr($buffer, $this->amr_mode_bytes_per_frame($codec_mode_request));
} while (strlen($buffer) > 0);
$info['playtime_seconds'] = array_sum($thisfile_amr['frame_mode_count']) * 0.02;
// each frame contain 160 samples and is 20 milliseconds long
$info['audio']['bitrate'] = 8 * ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'];
// bitrate could be calculated from average bitrate by distributation of frame types. That would give effective audio bitrate, this gives overall file bitrate which will be a little bit higher since every frame will waste 8 bits for header, plus a few bits for octet padding
$info['bitrate'] = $info['audio']['bitrate'];
return true;
}
示例12: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$DSSheader = fread($this->getid3->fp, 1256);
if (!preg_match('#^(\\x02|\\x03)ds[s2]#', $DSSheader)) {
$info['error'][] = 'Expecting "[02-03] 64 73 [73|32]" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($DSSheader, 0, 4)) . '"';
return false;
}
// some structure information taken from http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm
$info['encoding'] = 'ISO-8859-1';
// not certain, but assumed
$info['dss'] = array();
$info['fileformat'] = 'dss';
$info['mime_type'] = 'audio/x-' . substr($DSSheader, 1, 3);
// "audio/x-dss" or "audio/x-ds2"
$info['audio']['dataformat'] = substr($DSSheader, 1, 3);
// "dss" or "ds2"
$info['audio']['bitrate_mode'] = 'cbr';
$info['dss']['version'] = ord(substr($DSSheader, 0, 1));
$info['dss']['hardware'] = trim(substr($DSSheader, 12, 16));
// identification string for hardware used to create the file, e.g. "DPM 9600", "DS2400"
$info['dss']['unknown1'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 28, 4));
// 32-37 = "FE FF FE FF F7 FF" in all the sample files I've seen
$info['dss']['date_create'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 38, 12));
$info['dss']['date_complete'] = $this->DSSdateStringToUnixDate(substr($DSSheader, 50, 12));
$info['dss']['playtime_sec'] = intval(substr($DSSheader, 62, 2) * 3600 + substr($DSSheader, 64, 2) * 60 + substr($DSSheader, 66, 2));
// approximate file playtime in HHMMSS
$info['dss']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($DSSheader, 512, 4));
// exact file playtime in milliseconds. Has also been observed at offset 530 in one sample file, with something else (unknown) at offset 512
$info['dss']['priority'] = ord(substr($DSSheader, 793, 1));
$info['dss']['comments'] = trim(substr($DSSheader, 798, 100));
//$info['audio']['bits_per_sample'] = ?;
//$info['audio']['sample_rate'] = ?;
$info['audio']['channels'] = 1;
$info['playtime_seconds'] = $info['dss']['playtime_ms'] / 1000;
if (floor($info['dss']['playtime_ms'] / 1000) != $info['dss']['playtime_sec']) {
// *should* just be playtime_ms / 1000 but at least one sample file has playtime_ms at offset 530 instead of offset 512, so safety check
$info['playtime_seconds'] = $info['dss']['playtime_sec'];
$this->getid3->warning('playtime_ms (' . number_format($info['dss']['playtime_ms'] / 1000, 3) . ') does not match playtime_sec (' . number_format($info['dss']['playtime_sec']) . ') - using playtime_sec value');
}
$info['audio']['bitrate'] = $info['filesize'] * 8 / $info['playtime_seconds'];
return true;
}
示例13: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
$info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() [' . $this->getid3->version() . ']';
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$fileTypeID = fread($this->getid3->fp, 3);
switch ($fileTypeID) {
case 'BIK':
return $this->ParseBink();
break;
case 'SMK':
return $this->ParseSmacker();
break;
default:
$info['error'][] = 'Expecting "BIK" or "SMK" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes($fileTypeID) . '"';
return false;
break;
}
return true;
}
示例14: Analyze
public function Analyze()
{
$info =& $this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$AUheader = fread($this->getid3->fp, 8);
$magic = '.snd';
if (substr($AUheader, 0, 4) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" (".snd") at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($AUheader, 0, 4)) . '"';
return false;
}
// shortcut
$info['au'] = array();
$thisfile_au =& $info['au'];
$info['fileformat'] = 'au';
$info['audio']['dataformat'] = 'au';
$info['audio']['bitrate_mode'] = 'cbr';
$thisfile_au['encoding'] = 'ISO-8859-1';
$thisfile_au['header_length'] = getid3_lib::BigEndian2Int(substr($AUheader, 4, 4));
$AUheader .= fread($this->getid3->fp, $thisfile_au['header_length'] - 8);
$info['avdataoffset'] += $thisfile_au['header_length'];
$thisfile_au['data_size'] = getid3_lib::BigEndian2Int(substr($AUheader, 8, 4));
$thisfile_au['data_format_id'] = getid3_lib::BigEndian2Int(substr($AUheader, 12, 4));
$thisfile_au['sample_rate'] = getid3_lib::BigEndian2Int(substr($AUheader, 16, 4));
$thisfile_au['channels'] = getid3_lib::BigEndian2Int(substr($AUheader, 20, 4));
$thisfile_au['comments']['comment'][] = trim(substr($AUheader, 24));
$thisfile_au['data_format'] = $this->AUdataFormatNameLookup($thisfile_au['data_format_id']);
$thisfile_au['used_bits_per_sample'] = $this->AUdataFormatUsedBitsPerSampleLookup($thisfile_au['data_format_id']);
if ($thisfile_au['bits_per_sample'] = $this->AUdataFormatBitsPerSampleLookup($thisfile_au['data_format_id'])) {
$info['audio']['bits_per_sample'] = $thisfile_au['bits_per_sample'];
} else {
unset($thisfile_au['bits_per_sample']);
}
$info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
$info['audio']['channels'] = $thisfile_au['channels'];
if ($info['avdataoffset'] + $thisfile_au['data_size'] > $info['avdataend']) {
$info['warning'][] = 'Possible truncated file - expecting "' . $thisfile_au['data_size'] . '" bytes of audio data, only found ' . ($info['avdataend'] - $info['avdataoffset']) . ' bytes"';
}
$info['playtime_seconds'] = $thisfile_au['data_size'] / ($thisfile_au['sample_rate'] * $thisfile_au['channels'] * ($thisfile_au['used_bits_per_sample'] / 8));
$info['audio']['bitrate'] = $thisfile_au['data_size'] * 8 / $info['playtime_seconds'];
return true;
}
示例15: ParseOptimFROGheader45
//.........這裏部分代碼省略.........
}
}
}
$ThisFileInfo['audio']['channels'] = $thisfile_ofr_thisblock['channels'];
$ThisFileInfo['audio']['sample_rate'] = $thisfile_ofr_thisblock['sample_rate'];
$ThisFileInfo['audio']['bits_per_sample'] = $this->OptimFROGbitsPerSampleTypeLookup($thisfile_ofr_thisblock['raw']['sample_type']);
break;
case 'COMP':
// unlike other block types, there CAN be multiple COMP blocks
$COMPdata['offset'] = $BlockOffset;
$COMPdata['size'] = $BlockSize;
if ($ThisFileInfo['avdataoffset'] == 0) {
$ThisFileInfo['avdataoffset'] = $BlockOffset;
}
// Only interested in first 14 bytes (only first 12 needed for v4.50 alpha), not actual audio data
$BlockData .= fread($fd, 14);
fseek($fd, $BlockSize - 14, SEEK_CUR);
$COMPdata['crc_32'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4));
$offset += 4;
$COMPdata['sample_count'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 4));
$offset += 4;
$COMPdata['raw']['sample_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1));
$COMPdata['sample_type'] = $this->OptimFROGsampleTypeLookup($COMPdata['raw']['sample_type']);
$offset += 1;
$COMPdata['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 1));
$COMPdata['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($COMPdata['raw']['channel_configuration']);
$offset += 1;
$COMPdata['raw']['algorithm_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2));
//$COMPdata['algorithm'] = OptimFROGalgorithmNameLookup($COMPdata['raw']['algorithm_id']);
$offset += 2;
if ($ThisFileInfo['ofr']['OFR ']['size'] > 12) {
// OFR 4.504b or higher
$COMPdata['raw']['encoder_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, $offset, 2));
$COMPdata['encoder'] = $this->OptimFROGencoderNameLookup($COMPdata['raw']['encoder_id']);
$offset += 2;
}
if ($COMPdata['crc_32'] == 0x454e4f4e) {
// ASCII value of 'NONE' - placeholder value in v4.50a
$COMPdata['crc_32'] = false;
}
$thisfile_ofr_thisblock[] = $COMPdata;
break;
case 'HEAD':
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$RIFFdata .= fread($fd, $BlockSize);
break;
case 'TAIL':
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
if ($BlockSize > 0) {
$RIFFdata .= fread($fd, $BlockSize);
}
break;
case 'RECV':
// block contains no useful meta data - simply note and skip
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
fseek($fd, $BlockSize, SEEK_CUR);
break;
case 'APET':
// APEtag v2
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$ThisFileInfo['warning'][] = 'APEtag processing inside OptimFROG not supported in this version (' . GETID3_VERSION . ') of getID3()';
fseek($fd, $BlockSize, SEEK_CUR);
break;
case 'MD5 ':
// APEtag v2
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
if ($BlockSize == 16) {
$thisfile_ofr_thisblock['md5_binary'] = fread($fd, $BlockSize);
$thisfile_ofr_thisblock['md5_string'] = getid3_lib::PrintHexBytes($thisfile_ofr_thisblock['md5_binary'], true, false, false);
$ThisFileInfo['md5_data_source'] = $thisfile_ofr_thisblock['md5_string'];
} else {
$ThisFileInfo['warning'][] = 'Expecting block size of 16 in "MD5 " chunk, found ' . $BlockSize . ' instead';
fseek($fd, $BlockSize, SEEK_CUR);
}
break;
default:
$thisfile_ofr_thisblock['offset'] = $BlockOffset;
$thisfile_ofr_thisblock['size'] = $BlockSize;
$ThisFileInfo['warning'][] = 'Unhandled OptimFROG block type "' . $BlockName . '" at offset ' . $thisfile_ofr_thisblock['offset'];
fseek($fd, $BlockSize, SEEK_CUR);
break;
}
}
if (isset($ThisFileInfo['ofr']['TAIL']['offset'])) {
$ThisFileInfo['avdataend'] = $ThisFileInfo['ofr']['TAIL']['offset'];
}
$ThisFileInfo['playtime_seconds'] = (double) $ThisFileInfo['ofr']['OFR ']['total_samples'] / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate']);
$ThisFileInfo['audio']['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['playtime_seconds'];
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
$RIFFdata = substr($RIFFdata, 0, 36) . substr($RIFFdata, 44) . substr($RIFFdata, 36, 8);
getid3_riff::ParseRIFFdata($RIFFdata, $ThisFileInfo);
return true;
}