22 $info = &$this->getid3->info;
26 $ShortenHeader = $this->
fread(8);
28 if (substr($ShortenHeader, 0, 4) != $magic) {
32 $info[
'fileformat'] =
'shn';
33 $info[
'audio'][
'dataformat'] =
'shn';
34 $info[
'audio'][
'lossless'] =
true;
35 $info[
'audio'][
'bitrate_mode'] =
'vbr';
40 $SeekTableSignatureTest = $this->
fread(12);
41 $info[
'shn'][
'seektable'][
'present'] = (bool) (substr($SeekTableSignatureTest, 4, 8) ==
'SHNAMPSK');
42 if (
$info[
'shn'][
'seektable'][
'present']) {
44 $info[
'shn'][
'seektable'][
'offset'] =
$info[
'avdataend'] -
$info[
'shn'][
'seektable'][
'length'];
45 $this->
fseek($info[
'shn'][
'seektable'][
'offset']);
46 $SeekTableMagic = $this->
fread(4);
48 if ($SeekTableMagic != $magic) {
71 $SeekTableData = $this->
fread($info[
'shn'][
'seektable'][
'length'] - 16);
72 $info[
'shn'][
'seektable'][
'entry_count'] = floor(strlen($SeekTableData) / 80);
116 if (preg_match(
'#(1|ON)#i', ini_get(
'safe_mode'))) {
117 $this->
error(
'PHP running in Safe Mode - backtick operator not available, cannot run shntool to analyze Shorten files');
121 if (GETID3_OS_ISWINDOWS) {
123 $RequiredFiles =
array(
'shorten.exe',
'cygwin1.dll',
'head.exe');
124 foreach ($RequiredFiles as $required_file) {
125 if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
126 $this->
error(GETID3_HELPERAPPSDIR.$required_file.
' does not exist');
130 $commandline = GETID3_HELPERAPPSDIR.
'shorten.exe -x "'.
$info[
'filenamepath'].
'" - | '.GETID3_HELPERAPPSDIR.
'head.exe -c 64';
131 $commandline = str_replace(
'/',
'\\', $commandline);
135 static $shorten_present;
136 if (!isset($shorten_present)) {
137 $shorten_present = file_exists(
'/usr/local/bin/shorten') || `which shorten`;
139 if (!$shorten_present) {
140 $this->
error(
'shorten binary was not found in path or /usr/local/bin');
143 $commandline = (file_exists(
'/usr/local/bin/shorten') ?
'/usr/local/bin/' :
'' ) .
'shorten -x '.escapeshellarg(
$info[
'filenamepath']).
' - | head -c 64';
155 $info[
'audio'][
'channels'] = $DecodedWAVFORMATEX[
'channels'];
156 $info[
'audio'][
'bits_per_sample'] = $DecodedWAVFORMATEX[
'bits_per_sample'];
157 $info[
'audio'][
'sample_rate'] = $DecodedWAVFORMATEX[
'sample_rate'];
159 if (substr(
$output, 20 + $fmt_size, 4) ==
'data') {
165 $this->
error(
'shorten failed to decode DATA chunk to expected location, cannot determine playtime');
170 $info[
'audio'][
'bitrate'] = ((
$info[
'avdataend'] -
$info[
'avdataoffset']) /
$info[
'playtime_seconds']) * 8;
174 $this->
error(
'shorten failed to decode file to WAV for parsing');
static parseWAVEFORMATex($WaveFormatExData)
static LittleEndian2Int($byteword, $signed=false)
static IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Create styles array
The data for the language used.
getID3() by James Heinrich info@getid3.org //
fseek($bytes, $whence=SEEK_SET)