92 $info = &$this->getid3->info;
94 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
96 $FLVdataLength =
$info[
'avdataend'] -
$info[
'avdataoffset'];
97 $FLVheader =
fread($this->getid3->fp, 5);
99 $info[
'fileformat'] =
'flv';
100 $info[
'flv'][
'header'][
'signature'] = substr($FLVheader, 0, 3);
107 if ($info[
'flv'][
'header'][
'signature'] != $magic) {
110 unset($info[
'fileformat']);
115 $info[
'flv'][
'header'][
'hasAudio'] = (bool) ($TypeFlags & 0x04);
116 $info[
'flv'][
'header'][
'hasVideo'] = (bool) ($TypeFlags & 0x01);
120 $FLVheaderFrameLength = 9;
121 if ($FrameSizeDataLength > $FLVheaderFrameLength) {
122 fseek($this->getid3->fp,
123 $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
126 $found_video =
false;
127 $found_audio =
false;
129 $found_valid_meta_playtime =
false;
131 $info[
'flv'][
'framecount'] =
array(
'total' => 0,
'audio' => 0,
'video' => 0);
132 $flv_framecount = &$info[
'flv'][
'framecount'];
133 while (((
ftell($this->getid3->fp) + 16) < $info[
'avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
134 $ThisTagHeader =
fread($this->getid3->fp, 16);
146 $NextOffset =
ftell($this->getid3->fp) - 1 + $DataLength;
147 if ($Timestamp > $Duration) {
148 $Duration = $Timestamp;
151 $flv_framecount[
'total']++;
153 case self::GETID3_FLV_TAG_AUDIO:
154 $flv_framecount[
'audio']++;
157 $info[
'flv'][
'audio'][
'audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
158 $info[
'flv'][
'audio'][
'audioRate'] = ($LastHeaderByte >> 2) & 0x03;
159 $info[
'flv'][
'audio'][
'audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
160 $info[
'flv'][
'audio'][
'audioType'] = $LastHeaderByte & 0x01;
164 case self::GETID3_FLV_TAG_VIDEO:
165 $flv_framecount[
'video']++;
168 $info[
'flv'][
'video'][
'videoCodec'] = $LastHeaderByte & 0x07;
170 $FLVvideoHeader =
fread($this->getid3->fp, 11);
172 if ($info[
'flv'][
'video'][
'videoCodec'] == self::GETID3_FLV_VIDEO_H264) {
196 if (($numOfSequenceParameterSets & 0x1F) != 0) {
204 $sps =
fread($this->getid3->fp, $spsSize);
205 if (strlen($sps) == $spsSize) {
207 $spsReader->readData();
208 $info[
'video'][
'resolution_x'] = $spsReader->getWidth();
209 $info[
'video'][
'resolution_y'] = $spsReader->getHeight();
214 } elseif ($info[
'flv'][
'video'][
'videoCodec'] == self::GETID3_FLV_VIDEO_H263) {
219 $PictureSizeType = $PictureSizeType & 0x0007;
220 $info[
'flv'][
'header'][
'videoSizeType'] = $PictureSizeType;
221 switch ($PictureSizeType) {
236 $PictureSizeEnc[
'x'] >>= 7;
237 $PictureSizeEnc[
'y'] >>= 7;
238 $info[
'video'][
'resolution_x'] = $PictureSizeEnc[
'x'] & 0xFF;
239 $info[
'video'][
'resolution_y'] = $PictureSizeEnc[
'y'] & 0xFF;
249 $PictureSizeEnc[
'x'] >>= 7;
250 $PictureSizeEnc[
'y'] >>= 7;
251 $info[
'video'][
'resolution_x'] = $PictureSizeEnc[
'x'] & 0xFFFF;
252 $info[
'video'][
'resolution_y'] = $PictureSizeEnc[
'y'] & 0xFFFF;
256 $info[
'video'][
'resolution_x'] = 352;
257 $info[
'video'][
'resolution_y'] = 288;
261 $info[
'video'][
'resolution_x'] = 176;
262 $info[
'video'][
'resolution_y'] = 144;
266 $info[
'video'][
'resolution_x'] = 128;
267 $info[
'video'][
'resolution_y'] = 96;
271 $info[
'video'][
'resolution_x'] = 320;
272 $info[
'video'][
'resolution_y'] = 240;
276 $info[
'video'][
'resolution_x'] = 160;
277 $info[
'video'][
'resolution_y'] = 120;
281 $info[
'video'][
'resolution_x'] = 0;
282 $info[
'video'][
'resolution_y'] = 0;
286 $info[
'video'][
'pixel_aspect_ratio'] = $info[
'video'][
'resolution_x'] / $info[
'video'][
'resolution_y'];
291 case self::GETID3_FLV_TAG_META:
294 fseek($this->getid3->fp, -1, SEEK_CUR);
295 $datachunk =
fread($this->getid3->fp, $DataLength);
298 $eventName =
$reader->readData();
299 $info[
'flv'][
'meta'][$eventName] =
$reader->readData();
302 $copykeys =
array(
'framerate' =>
'frame_rate',
'width' =>
'resolution_x',
'height' =>
'resolution_y',
'audiodatarate' =>
'bitrate',
'videodatarate' =>
'bitrate');
303 foreach ($copykeys as $sourcekey => $destkey) {
304 if (isset($info[
'flv'][
'meta'][
'onMetaData'][$sourcekey])) {
305 switch ($sourcekey) {
308 $info[
'video'][$destkey] = intval(round($info[
'flv'][
'meta'][
'onMetaData'][$sourcekey]));
310 case 'audiodatarate':
311 $info[
'audio'][$destkey] =
Helper::CastAsInt(round($info[
'flv'][
'meta'][
'onMetaData'][$sourcekey] * 1000));
313 case 'videodatarate':
316 $info[
'video'][$destkey] = $info[
'flv'][
'meta'][
'onMetaData'][$sourcekey];
321 if (!empty($info[
'flv'][
'meta'][
'onMetaData'][
'duration'])) {
322 $found_valid_meta_playtime =
true;
331 fseek($this->getid3->fp, $NextOffset, SEEK_SET);
334 $info[
'playtime_seconds'] = $Duration / 1000;
335 if ($info[
'playtime_seconds'] > 0) {
336 $info[
'bitrate'] = (($info[
'avdataend'] - $info[
'avdataoffset']) * 8) / $info[
'playtime_seconds'];
339 if ($info[
'flv'][
'header'][
'hasAudio']) {
340 $info[
'audio'][
'codec'] = $this->
FLVaudioFormat($info[
'flv'][
'audio'][
'audioFormat']);
341 $info[
'audio'][
'sample_rate'] = $this->
FLVaudioRate($info[
'flv'][
'audio'][
'audioRate']);
342 $info[
'audio'][
'bits_per_sample'] = $this->
FLVaudioBitDepth($info[
'flv'][
'audio'][
'audioSampleSize']);
344 $info[
'audio'][
'channels'] = $info[
'flv'][
'audio'][
'audioType'] + 1;
345 $info[
'audio'][
'lossless'] = ($info[
'flv'][
'audio'][
'audioFormat'] ? false :
true);
346 $info[
'audio'][
'dataformat'] =
'flv';
348 if (!empty($info[
'flv'][
'header'][
'hasVideo'])) {
349 $info[
'video'][
'codec'] = $this->
FLVvideoCodec($info[
'flv'][
'video'][
'videoCodec']);
350 $info[
'video'][
'dataformat'] =
'flv';
351 $info[
'video'][
'lossless'] =
false;
355 if (!empty($info[
'flv'][
'meta'][
'onMetaData'][
'duration'])) {
356 $info[
'playtime_seconds'] = $info[
'flv'][
'meta'][
'onMetaData'][
'duration'];
357 $info[
'bitrate'] = (($info[
'avdataend'] - $info[
'avdataoffset']) * 8) / $info[
'playtime_seconds'];
359 if (isset($info[
'flv'][
'meta'][
'onMetaData'][
'audiocodecid'])) {
360 $info[
'audio'][
'codec'] = $this->
FLVaudioFormat($info[
'flv'][
'meta'][
'onMetaData'][
'audiocodecid']);
362 if (isset($info[
'flv'][
'meta'][
'onMetaData'][
'videocodecid'])) {
363 $info[
'video'][
'codec'] = $this->
FLVvideoCodec($info[
'flv'][
'meta'][
'onMetaData'][
'videocodecid']);
376 $FLVaudioFormat =
array(
377 0 =>
'Linear PCM, platform endian',
380 3 =>
'Linear PCM, little endian',
381 4 =>
'Nellymoser 16kHz mono',
382 5 =>
'Nellymoser 8kHz mono',
384 7 =>
'G.711A-law logarithmic PCM',
385 8 =>
'G.711 mu-law logarithmic PCM',
392 15 =>
'Device-specific sound',
395 return (isset($FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] :
false);
405 $FLVaudioRate =
array(
412 return (isset($FLVaudioRate[$id]) ? $FLVaudioRate[$id] :
false);
422 $FLVaudioBitDepth =
array(
427 return (isset($FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] :
false);
437 $FLVvideoCodec =
array(
438 self::GETID3_FLV_VIDEO_H263 =>
'Sorenson H.263',
439 self::GETID3_FLV_VIDEO_SCREEN =>
'Screen video',
440 self::GETID3_FLV_VIDEO_VP6FLV =>
'On2 VP6',
441 self::GETID3_FLV_VIDEO_VP6FLV_ALPHA =>
'On2 VP6 with alpha channel',
442 self::GETID3_FLV_VIDEO_SCREENV2 =>
'Screen video v2',
443 self::GETID3_FLV_VIDEO_H264 =>
'Sorenson H.264',
446 return (isset($FLVvideoCodec[$id]) ? $FLVvideoCodec[$id] :
false);
const GETID3_FLV_VIDEO_SCREEN
GetId3() by James Heinrich info@getid3.org //.
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
const GETID3_FLV_TAG_VIDEO
const H264_AVC_SEQUENCE_HEADER
GetId3() by James Heinrich info@getid3.org //.
const GETID3_FLV_VIDEO_H263
const GETID3_FLV_VIDEO_VP6FLV_ALPHA
const GETID3_FLV_TAG_META
fseek($bytes, $whence=SEEK_SET)
const GETID3_FLV_VIDEO_VP6FLV
const GETID3_FLV_TAG_AUDIO
const GETID3_FLV_VIDEO_H264
GetId3() by James Heinrich info@getid3.org //.
static CastAsInt($floatnum)
Create styles array
The data for the language used.
const GETID3_FLV_VIDEO_SCREENV2
static LittleEndian2Int($byteword, $signed=false)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.