ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_flv Class Reference
+ Inheritance diagram for getid3_flv:
+ Collaboration diagram for getid3_flv:

Public Member Functions

 getid3_flv (&$fd, &$ThisFileInfo, $ReturnAllTagData=false)
 
 FLVaudioFormat ($id)
 
 FLVaudioRate ($id)
 
 FLVaudioBitDepth ($id)
 
 FLVvideoCodec ($id)
 
 Analyze ()
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Static Public Member Functions

static audioFormatLookup ($id)
 
static audioRateLookup ($id)
 
static audioBitDepthLookup ($id)
 
static videoCodecLookup ($id)
 

Data Fields

const magic = 'FLV'
 
 $max_frames = 100000
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

Definition at line 38 of file module.audio-video.flv.php.

Member Function Documentation

◆ Analyze()

getid3_flv::Analyze ( )

Reimplemented from getid3_handler.

Definition at line 82 of file module.audio-video.flv.php.

82 {
83 $info = &$this->getid3->info;
84
85 $this->fseek($info['avdataoffset']);
86
87 $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
88 $FLVheader = $this->fread(5);
89
90 $info['fileformat'] = 'flv';
91 $info['flv']['header']['signature'] = substr($FLVheader, 0, 3);
92 $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
93 $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
94
95 if ($info['flv']['header']['signature'] != self::magic) {
96 $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"';
97 unset($info['flv'], $info['fileformat']);
98 return false;
99 }
100
101 $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
102 $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
103
104 $FrameSizeDataLength = getid3_lib::BigEndian2Int($this->fread(4));
105 $FLVheaderFrameLength = 9;
106 if ($FrameSizeDataLength > $FLVheaderFrameLength) {
107 $this->fseek($FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
108 }
109 $Duration = 0;
110 $found_video = false;
111 $found_audio = false;
112 $found_meta = false;
113 $found_valid_meta_playtime = false;
114 $tagParseCount = 0;
115 $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0);
116 $flv_framecount = &$info['flv']['framecount'];
117 while ((($this->ftell() + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
118 $ThisTagHeader = $this->fread(16);
119
120 $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
121 $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
122 $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
123 $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
124 $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
125 $NextOffset = $this->ftell() - 1 + $DataLength;
126 if ($Timestamp > $Duration) {
127 $Duration = $Timestamp;
128 }
129
130 $flv_framecount['total']++;
131 switch ($TagType) {
133 $flv_framecount['audio']++;
134 if (!$found_audio) {
135 $found_audio = true;
136 $info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
137 $info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03;
138 $info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
139 $info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01;
140 }
141 break;
142
144 $flv_framecount['video']++;
145 if (!$found_video) {
146 $found_video = true;
147 $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
148
149 $FLVvideoHeader = $this->fread(11);
150
151 if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
152 // this code block contributed by: moysevichØgmail*com
153
154 $AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1));
155 if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) {
156 // read AVCDecoderConfigurationRecord
157 $configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1));
158 $AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1));
159 $profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1));
160 $lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1));
161 $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1));
162
163 if (($numOfSequenceParameterSets & 0x1F) != 0) {
164 // there is at least one SequenceParameterSet
165 // read size of the first SequenceParameterSet
166 //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));
167 $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
168 // read the first SequenceParameterSet
169 $sps = $this->fread($spsSize);
170 if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red
171 $spsReader = new AVCSequenceParameterSetReader($sps);
172 $spsReader->readData();
173 $info['video']['resolution_x'] = $spsReader->getWidth();
174 $info['video']['resolution_y'] = $spsReader->getHeight();
175 }
176 }
177 }
178 // end: moysevichØgmail*com
179
180 } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) {
181
182 $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
183 $PictureSizeType = $PictureSizeType & 0x0007;
184 $info['flv']['header']['videoSizeType'] = $PictureSizeType;
185 switch ($PictureSizeType) {
186 case 0:
187 //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
188 //$PictureSizeEnc <<= 1;
189 //$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
190 //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
191 //$PictureSizeEnc <<= 1;
192 //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
193
194 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2)) >> 7;
195 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)) >> 7;
196 $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
197 $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
198 break;
199
200 case 1:
201 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3)) >> 7;
202 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3)) >> 7;
203 $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
204 $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
205 break;
206
207 case 2:
208 $info['video']['resolution_x'] = 352;
209 $info['video']['resolution_y'] = 288;
210 break;
211
212 case 3:
213 $info['video']['resolution_x'] = 176;
214 $info['video']['resolution_y'] = 144;
215 break;
216
217 case 4:
218 $info['video']['resolution_x'] = 128;
219 $info['video']['resolution_y'] = 96;
220 break;
221
222 case 5:
223 $info['video']['resolution_x'] = 320;
224 $info['video']['resolution_y'] = 240;
225 break;
226
227 case 6:
228 $info['video']['resolution_x'] = 160;
229 $info['video']['resolution_y'] = 120;
230 break;
231
232 default:
233 $info['video']['resolution_x'] = 0;
234 $info['video']['resolution_y'] = 0;
235 break;
236
237 }
238
239 } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_VP6FLV_ALPHA) {
240
241 /* contributed by schouwerwouØgmail*com */
242 if (!isset($info['video']['resolution_x'])) { // only when meta data isn't set
243 $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
244 $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 2));
245 $info['video']['resolution_x'] = ($PictureSizeEnc['x'] & 0xFF) << 3;
246 $info['video']['resolution_y'] = ($PictureSizeEnc['y'] & 0xFF) << 3;
247 }
248 /* end schouwerwouØgmail*com */
249
250 }
251 if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) {
252 $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
253 }
254 }
255 break;
256
257 // Meta tag
259 if (!$found_meta) {
260 $found_meta = true;
261 $this->fseek(-1, SEEK_CUR);
262 $datachunk = $this->fread($DataLength);
263 $AMFstream = new AMFStream($datachunk);
264 $reader = new AMFReader($AMFstream);
265 $eventName = $reader->readData();
266 $info['flv']['meta'][$eventName] = $reader->readData();
267 unset($reader);
268
269 $copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate');
270 foreach ($copykeys as $sourcekey => $destkey) {
271 if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
272 switch ($sourcekey) {
273 case 'width':
274 case 'height':
275 $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
276 break;
277 case 'audiodatarate':
278 $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
279 break;
280 case 'videodatarate':
281 case 'frame_rate':
282 default:
283 $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
284 break;
285 }
286 }
287 }
288 if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
289 $found_valid_meta_playtime = true;
290 }
291 }
292 break;
293
294 default:
295 // noop
296 break;
297 }
298 $this->fseek($NextOffset);
299 }
300
301 $info['playtime_seconds'] = $Duration / 1000;
302 if ($info['playtime_seconds'] > 0) {
303 $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
304 }
305
306 if ($info['flv']['header']['hasAudio']) {
307 $info['audio']['codec'] = self::audioFormatLookup($info['flv']['audio']['audioFormat']);
308 $info['audio']['sample_rate'] = self::audioRateLookup($info['flv']['audio']['audioRate']);
309 $info['audio']['bits_per_sample'] = self::audioBitDepthLookup($info['flv']['audio']['audioSampleSize']);
310
311 $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
312 $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
313 $info['audio']['dataformat'] = 'flv';
314 }
315 if (!empty($info['flv']['header']['hasVideo'])) {
316 $info['video']['codec'] = self::videoCodecLookup($info['flv']['video']['videoCodec']);
317 $info['video']['dataformat'] = 'flv';
318 $info['video']['lossless'] = false;
319 }
320
321 // Set information from meta
322 if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
323 $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
324 $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
325 }
326 if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
327 $info['audio']['codec'] = self::audioFormatLookup($info['flv']['meta']['onMetaData']['audiocodecid']);
328 }
329 if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
330 $info['video']['codec'] = self::videoCodecLookup($info['flv']['meta']['onMetaData']['videocodecid']);
331 }
332 return true;
333 }
static audioBitDepthLookup($id)
static audioFormatLookup($id)
static videoCodecLookup($id)
static audioRateLookup($id)
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
fread($bytes)
Definition: getid3.php:1685
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266
CastAsInt($floatnum)
Definition: getid3.lib.php:60
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true)
Definition: getid3.lib.php:17
$info
Definition: example_052.php:80
const GETID3_FLV_TAG_AUDIO
getID3() by James Heinrich info@getid3.org //
const GETID3_FLV_TAG_VIDEO
const GETID3_FLV_VIDEO_H263
const GETID3_FLV_TAG_META
const H264_AVC_SEQUENCE_HEADER
const GETID3_FLV_VIDEO_VP6FLV_ALPHA
const GETID3_FLV_VIDEO_H264

References $info, $reader, audioBitDepthLookup(), audioFormatLookup(), audioRateLookup(), getid3_lib\BigEndian2Int(), getid3_lib\CastAsInt(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), GETID3_FLV_TAG_AUDIO, GETID3_FLV_TAG_META, GETID3_FLV_TAG_VIDEO, GETID3_FLV_VIDEO_H263, GETID3_FLV_VIDEO_H264, GETID3_FLV_VIDEO_VP6FLV_ALPHA, H264_AVC_SEQUENCE_HEADER, getid3_lib\LittleEndian2Int(), getid3_lib\PrintHexBytes(), and videoCodecLookup().

+ Here is the call graph for this function:

◆ audioBitDepthLookup()

static getid3_flv::audioBitDepthLookup (   $id)
static

Definition at line 368 of file module.audio-video.flv.php.

368 {
369 static $lookup = array(
370 0 => 8,
371 1 => 16,
372 );
373 return (isset($lookup[$id]) ? $lookup[$id] : false);
374 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ audioFormatLookup()

static getid3_flv::audioFormatLookup (   $id)
static

Definition at line 336 of file module.audio-video.flv.php.

336 {
337 static $lookup = array(
338 0 => 'Linear PCM, platform endian',
339 1 => 'ADPCM',
340 2 => 'mp3',
341 3 => 'Linear PCM, little endian',
342 4 => 'Nellymoser 16kHz mono',
343 5 => 'Nellymoser 8kHz mono',
344 6 => 'Nellymoser',
345 7 => 'G.711A-law logarithmic PCM',
346 8 => 'G.711 mu-law logarithmic PCM',
347 9 => 'reserved',
348 10 => 'AAC',
349 11 => 'Speex',
350 12 => false, // unknown?
351 13 => false, // unknown?
352 14 => 'mp3 8kHz',
353 15 => 'Device-specific sound',
354 );
355 return (isset($lookup[$id]) ? $lookup[$id] : false);
356 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ audioRateLookup()

static getid3_flv::audioRateLookup (   $id)
static

Definition at line 358 of file module.audio-video.flv.php.

358 {
359 static $lookup = array(
360 0 => 5500,
361 1 => 11025,
362 2 => 22050,
363 3 => 44100,
364 );
365 return (isset($lookup[$id]) ? $lookup[$id] : false);
366 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ FLVaudioBitDepth()

getid3_flv::FLVaudioBitDepth (   $id)

Definition at line 230 of file module.audio-video.flv.php.

230 {
231 $FLVaudioBitDepth = array(
232 0 => 8,
233 1 => 16,
234 );
235 return (@$FLVaudioBitDepth[$id] ? @$FLVaudioBitDepth[$id] : false);
236 }

Referenced by getid3_flv().

+ Here is the caller graph for this function:

◆ FLVaudioFormat()

getid3_flv::FLVaudioFormat (   $id)

Definition at line 209 of file module.audio-video.flv.php.

209 {
210 $FLVaudioFormat = array(
211 0 => 'uncompressed',
212 1 => 'ADPCM',
213 2 => 'mp3',
214 5 => 'Nellymoser 8kHz mono',
215 6 => 'Nellymoser',
216 );
217 return (@$FLVaudioFormat[$id] ? @$FLVaudioFormat[$id] : false);
218 }

Referenced by getid3_flv().

+ Here is the caller graph for this function:

◆ FLVaudioRate()

getid3_flv::FLVaudioRate (   $id)

Definition at line 220 of file module.audio-video.flv.php.

220 {
221 $FLVaudioRate = array(
222 0 => 5500,
223 1 => 11025,
224 2 => 22050,
225 3 => 44100,
226 );
227 return (@$FLVaudioRate[$id] ? @$FLVaudioRate[$id] : false);
228 }

Referenced by getid3_flv().

+ Here is the caller graph for this function:

◆ FLVvideoCodec()

getid3_flv::FLVvideoCodec (   $id)

Definition at line 238 of file module.audio-video.flv.php.

238 {
239 $FLVvideoCodec = array(
240 GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
241 GETID3_FLV_VIDEO_SCREEN => 'Screen video',
242 GETID3_FLV_VIDEO_VP6 => 'On2 VP6',
243 );
244 return (@$FLVvideoCodec[$id] ? @$FLVvideoCodec[$id] : false);
245 }
const GETID3_FLV_VIDEO_SCREEN
const GETID3_FLV_VIDEO_VP6

References GETID3_FLV_VIDEO_H263, GETID3_FLV_VIDEO_SCREEN, and GETID3_FLV_VIDEO_VP6.

Referenced by getid3_flv().

+ Here is the caller graph for this function:

◆ getid3_flv()

getid3_flv::getid3_flv ( $fd,
$ThisFileInfo,
  $ReturnAllTagData = false 
)

Definition at line 41 of file module.audio-video.flv.php.

41 {
42 fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
43
44 $FLVdataLength = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
45 $FLVheader = fread($fd, 5);
46
47 $ThisFileInfo['fileformat'] = 'flv';
48 $ThisFileInfo['flv']['header']['signature'] = substr($FLVheader, 0, 3);
49 $ThisFileInfo['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
50 $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
51
52 if ($ThisFileInfo['flv']['header']['signature'] != 'FLV') {
53 $ThisFileInfo['error'][] = 'Expecting "FLV" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['flv']['header']['signature'].'"';
54 unset($ThisFileInfo['flv']);
55 unset($ThisFileInfo['fileformat']);
56 return false;
57 }
58
59 $ThisFileInfo['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
60 $ThisFileInfo['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
61
62 $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($fd, 4));
63 $FLVheaderFrameLength = 9;
64 if ($FrameSizeDataLength > $FLVheaderFrameLength) {
65 fseek($fd, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
66 }
67
68 $Duration = 0;
69 while ((ftell($fd) + 1) < $ThisFileInfo['avdataend']) {
70 //if (!$ThisFileInfo['flv']['header']['hasAudio'] || isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
71 // if (!$ThisFileInfo['flv']['header']['hasVideo'] || isset($ThisFileInfo['flv']['video']['videoCodec'])) {
72 // break;
73 // }
74 //}
75
76 $ThisTagHeader = fread($fd, 16);
77
78 $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
79 $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
80 $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
81 $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
82 $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
83 $NextOffset = ftell($fd) - 1 + $DataLength;
84
85 switch ($TagType) {
87 if (!isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
88 $ThisFileInfo['flv']['audio']['audioFormat'] = $LastHeaderByte & 0x07;
89 $ThisFileInfo['flv']['audio']['audioRate'] = ($LastHeaderByte & 0x30) / 0x10;
90 $ThisFileInfo['flv']['audio']['audioSampleSize'] = ($LastHeaderByte & 0x40) / 0x40;
91 $ThisFileInfo['flv']['audio']['audioType'] = ($LastHeaderByte & 0x80) / 0x80;
92 }
93 break;
94
96 if (!isset($ThisFileInfo['flv']['video']['videoCodec'])) {
97 $ThisFileInfo['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
98
99 $FLVvideoHeader = fread($fd, 11);
100
101 if ($ThisFileInfo['flv']['video']['videoCodec'] != GETID3_FLV_VIDEO_VP6) {
102
103 $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
104 $PictureSizeType = $PictureSizeType & 0x0007;
105 $ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType;
106 switch ($PictureSizeType) {
107 case 0:
108 $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
109 $PictureSizeEnc <<= 1;
110 $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
111 $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
112 $PictureSizeEnc <<= 1;
113 $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
114 break;
115
116 case 1:
117 $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 4));
118 $PictureSizeEnc <<= 1;
119 $ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFFFF0000) >> 16;
120
121 $PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 4));
122 $PictureSizeEnc <<= 1;
123 $ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFFFF0000) >> 16;
124 break;
125
126 case 2:
127 $ThisFileInfo['video']['resolution_x'] = 352;
128 $ThisFileInfo['video']['resolution_y'] = 288;
129 break;
130
131 case 3:
132 $ThisFileInfo['video']['resolution_x'] = 176;
133 $ThisFileInfo['video']['resolution_y'] = 144;
134 break;
135
136 case 4:
137 $ThisFileInfo['video']['resolution_x'] = 128;
138 $ThisFileInfo['video']['resolution_y'] = 96;
139 break;
140
141 case 5:
142 $ThisFileInfo['video']['resolution_x'] = 320;
143 $ThisFileInfo['video']['resolution_y'] = 240;
144 break;
145
146 case 6:
147 $ThisFileInfo['video']['resolution_x'] = 160;
148 $ThisFileInfo['video']['resolution_y'] = 120;
149 break;
150
151 default:
152 $ThisFileInfo['video']['resolution_x'] = 0;
153 $ThisFileInfo['video']['resolution_y'] = 0;
154 break;
155
156 }
157 }
158 }
159 break;
160
161 // Meta tag
163
164 fseek($fd, -1, SEEK_CUR);
165 $reader = new AMFReader(new AMFStream(fread($fd, $DataLength)));
166 $eventName = $reader->readData();
167 $ThisFileInfo['meta'][$eventName] = $reader->readData();
168 unset($reader);
169
170 $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['meta']['onMetaData']['framerate'];
171 $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['meta']['onMetaData']['width'];
172 $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['meta']['onMetaData']['height'];
173 break;
174
175 default:
176 // noop
177 break;
178 }
179
180 if ($Timestamp > $Duration) {
181 $Duration = $Timestamp;
182 }
183
184 fseek($fd, $NextOffset, SEEK_SET);
185 }
186
187 $ThisFileInfo['playtime_seconds'] = $Duration / 1000;
188 $ThisFileInfo['bitrate'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) / $ThisFileInfo['playtime_seconds'];
189
190 if ($ThisFileInfo['flv']['header']['hasAudio']) {
191 $ThisFileInfo['audio']['codec'] = $this->FLVaudioFormat($ThisFileInfo['flv']['audio']['audioFormat']);
192 $ThisFileInfo['audio']['sample_rate'] = $this->FLVaudioRate($ThisFileInfo['flv']['audio']['audioRate']);
193 $ThisFileInfo['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($ThisFileInfo['flv']['audio']['audioSampleSize']);
194
195 $ThisFileInfo['audio']['channels'] = $ThisFileInfo['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
196 $ThisFileInfo['audio']['lossless'] = ($ThisFileInfo['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
197 $ThisFileInfo['audio']['dataformat'] = 'flv';
198 }
199 if (@$ThisFileInfo['flv']['header']['hasVideo']) {
200 $ThisFileInfo['video']['codec'] = $this->FLVvideoCodec($ThisFileInfo['flv']['video']['videoCodec']);
201 $ThisFileInfo['video']['dataformat'] = 'flv';
202 $ThisFileInfo['video']['lossless'] = false;
203 }
204
205 return true;
206 }

References $reader, getid3_lib\BigEndian2Int(), FLVaudioBitDepth(), FLVaudioFormat(), FLVaudioRate(), FLVvideoCodec(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), GETID3_FLV_TAG_AUDIO, GETID3_FLV_TAG_META, GETID3_FLV_TAG_VIDEO, and GETID3_FLV_VIDEO_VP6.

+ Here is the call graph for this function:

◆ videoCodecLookup()

static getid3_flv::videoCodecLookup (   $id)
static

Definition at line 376 of file module.audio-video.flv.php.

376 {
377 static $lookup = array(
378 GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
379 GETID3_FLV_VIDEO_SCREEN => 'Screen video',
380 GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6',
381 GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel',
382 GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2',
383 GETID3_FLV_VIDEO_H264 => 'Sorenson H.264',
384 );
385 return (isset($lookup[$id]) ? $lookup[$id] : false);
386 }
const GETID3_FLV_VIDEO_VP6FLV
const GETID3_FLV_VIDEO_SCREENV2

References GETID3_FLV_VIDEO_H263, GETID3_FLV_VIDEO_H264, GETID3_FLV_VIDEO_SCREEN, GETID3_FLV_VIDEO_SCREENV2, GETID3_FLV_VIDEO_VP6FLV, and GETID3_FLV_VIDEO_VP6FLV_ALPHA.

Referenced by Analyze().

+ Here is the caller graph for this function:

Field Documentation

◆ $max_frames

getid3_flv::$max_frames = 100000

Definition at line 80 of file module.audio-video.flv.php.

◆ magic

const getid3_flv::magic = 'FLV'

Definition at line 78 of file module.audio-video.flv.php.


The documentation for this class was generated from the following files: