38 $info = &$this->getid3->info;
40 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
41 $NSVheader =
fread($this->getid3->fp, 4);
46 $info[
'fileformat'] =
'nsv';
47 $info[
'audio'][
'dataformat'] =
'nsv';
48 $info[
'video'][
'dataformat'] =
'nsv';
49 $info[
'audio'][
'lossless'] =
false;
50 $info[
'video'][
'lossless'] =
false;
56 $info[
'fileformat'] =
'nsv';
57 $info[
'audio'][
'dataformat'] =
'nsv';
58 $info[
'video'][
'dataformat'] =
'nsv';
59 $info[
'audio'][
'lossless'] =
false;
60 $info[
'video'][
'lossless'] =
false;
66 $info[
'error'][] =
'Expecting "NSVs" or "NSVf" at offset '.$info[
'avdataoffset'].
', found "'.
Helper::PrintHexBytes($NSVheader).
'"';
72 if (!isset(
$info[
'nsv'][
'NSVf'])) {
73 $info[
'warning'][] =
'NSVf header not present - cannot calculate playtime or bitrate';
86 $info = &$this->getid3->info;
87 fseek($this->getid3->fp, $fileoffset, SEEK_SET);
88 $NSVsheader =
fread($this->getid3->fp, 28);
91 $info[
'nsv'][
'NSVs'][
'identifier'] = substr($NSVsheader, $offset, 4);
94 if (
$info[
'nsv'][
'NSVs'][
'identifier'] !=
'NSVs') {
95 $info[
'error'][] =
'expected "NSVs" at offset ('.$fileoffset.
'), found "'.
$info[
'nsv'][
'NSVs'][
'identifier'].
'" instead';
96 unset(
$info[
'nsv'][
'NSVs']);
101 $info[
'nsv'][
'NSVs'][
'offset'] = $fileoffset;
103 $info[
'nsv'][
'NSVs'][
'video_codec'] = substr($NSVsheader, $offset, 4);
105 $info[
'nsv'][
'NSVs'][
'audio_codec'] = substr($NSVsheader, $offset, 4);
129 switch (
$info[
'nsv'][
'NSVs'][
'audio_codec']) {
138 $info[
'audio'][
'sample_rate'] =
$info[
'nsv'][
'NSVs'][
'sample_rate'];
149 $info[
'video'][
'resolution_x'] =
$info[
'nsv'][
'NSVs'][
'resolution_x'];
150 $info[
'video'][
'resolution_y'] =
$info[
'nsv'][
'NSVs'][
'resolution_y'];
152 $info[
'video'][
'frame_rate'] =
$info[
'nsv'][
'NSVs'][
'frame_rate'];
153 $info[
'video'][
'bits_per_sample'] = 24;
154 $info[
'video'][
'pixel_aspect_ratio'] = (float) 1;
167 $info = &$this->getid3->info;
168 fseek($this->getid3->fp, $fileoffset, SEEK_SET);
169 $NSVfheader =
fread($this->getid3->fp, 28);
172 $info[
'nsv'][
'NSVf'][
'identifier'] = substr($NSVfheader, $offset, 4);
175 if (
$info[
'nsv'][
'NSVf'][
'identifier'] !=
'NSVf') {
176 $info[
'error'][] =
'expected "NSVf" at offset ('.$fileoffset.
'), found "'.
$info[
'nsv'][
'NSVf'][
'identifier'].
'" instead';
177 unset(
$info[
'nsv'][
'NSVf']);
182 $info[
'nsv'][
'NSVs'][
'offset'] = $fileoffset;
189 if (
$info[
'nsv'][
'NSVf'][
'file_size'] >
$info[
'avdataend']) {
190 $info[
'warning'][] =
'truncated file - NSVf header indicates '.$info[
'nsv'][
'NSVf'][
'file_size'].
' bytes, file actually '.
$info[
'avdataend'].
' bytes';
202 if (
$info[
'nsv'][
'NSVf'][
'playtime_ms'] == 0) {
203 $info[
'error'][] =
'Corrupt NSV file: NSVf.playtime_ms == zero';
208 $NSVfheader .=
fread($this->getid3->fp,
$info[
'nsv'][
'NSVf'][
'meta_size'] + (4 *
$info[
'nsv'][
'NSVf'][
'TOC_entries_1']) + (4 *
$info[
'nsv'][
'NSVf'][
'TOC_entries_2']));
209 $NSVfheaderlength = strlen($NSVfheader);
210 $info[
'nsv'][
'NSVf'][
'metadata'] = substr($NSVfheader, $offset,
$info[
'nsv'][
'NSVf'][
'meta_size']);
211 $offset +=
$info[
'nsv'][
'NSVf'][
'meta_size'];
213 if ($getTOCoffsets) {
215 while ($TOCcounter <
$info[
'nsv'][
'NSVf'][
'TOC_entries_1']) {
216 if ($TOCcounter <
$info[
'nsv'][
'NSVf'][
'TOC_entries_1']) {
224 if (trim(
$info[
'nsv'][
'NSVf'][
'metadata']) !=
'') {
225 $info[
'nsv'][
'NSVf'][
'metadata'] = str_replace(
'`',
"\x01",
$info[
'nsv'][
'NSVf'][
'metadata']);
226 $CommentPairArray = explode(
"\x01".
' ',
$info[
'nsv'][
'NSVf'][
'metadata']);
227 foreach ($CommentPairArray as $CommentPair) {
228 if (strstr($CommentPair,
'='.
"\x01")) {
229 list($key, $value) = explode(
'='.
"\x01", $CommentPair, 2);
230 $info[
'nsv'][
'comments'][strtolower($key)][] = trim(str_replace(
"\x01",
'', $value));
235 $info[
'playtime_seconds'] =
$info[
'nsv'][
'NSVf'][
'playtime_ms'] / 1000;
236 $info[
'bitrate'] = (
$info[
'nsv'][
'NSVf'][
'file_size'] * 8) /
$info[
'playtime_seconds'];
249 if ($framerateindex <= 127) {
250 return (
float) $framerateindex;
252 static $NSVframerateLookup =
array();
253 if (empty($NSVframerateLookup)) {
254 $NSVframerateLookup[129] = (float) 29.970;
255 $NSVframerateLookup[131] = (float) 23.976;
256 $NSVframerateLookup[133] = (float) 14.985;
257 $NSVframerateLookup[197] = (float) 59.940;
258 $NSVframerateLookup[199] = (float) 47.952;
261 return (isset($NSVframerateLookup[$framerateindex]) ? $NSVframerateLookup[$framerateindex] :
false);
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
GetId3() by James Heinrich info@getid3.org //.
fseek($bytes, $whence=SEEK_SET)
getNSVsHeaderFilepointer($fileoffset)
static NSVframerateLookup($framerateindex)
array $NSVframerateLookup
Create styles array
The data for the language used.
GetId3() by James Heinrich info@getid3.org //.
static LittleEndian2Int($byteword, $signed=false)
getNSVfHeaderFilepointer($fileoffset, $getTOCoffsets=false)