ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
getid3_flv Class Reference
+ Collaboration diagram for getid3_flv:

Public Member Functions

 getid3_flv (&$fd, &$ThisFileInfo, $ReturnAllTagData=false)
 
 FLVaudioFormat ($id)
 
 FLVaudioRate ($id)
 
 FLVaudioBitDepth ($id)
 
 FLVvideoCodec ($id)
 

Detailed Description

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

Member Function Documentation

◆ FLVaudioBitDepth()

getid3_flv::FLVaudioBitDepth (   $id)

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

Referenced by getid3_flv().

230  {
231  $FLVaudioBitDepth = array(
232  0 => 8,
233  1 => 16,
234  );
235  return (@$FLVaudioBitDepth[$id] ? @$FLVaudioBitDepth[$id] : false);
236  }
+ Here is the caller graph for this function:

◆ FLVaudioFormat()

getid3_flv::FLVaudioFormat (   $id)

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

Referenced by getid3_flv().

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  }
+ Here is the caller graph for this function:

◆ FLVaudioRate()

getid3_flv::FLVaudioRate (   $id)

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

Referenced by getid3_flv().

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  }
+ Here is the caller graph for this function:

◆ FLVvideoCodec()

getid3_flv::FLVvideoCodec (   $id)

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

References GETID3_FLV_VIDEO_H263, GETID3_FLV_VIDEO_SCREEN, and GETID3_FLV_VIDEO_VP6.

Referenced by getid3_flv().

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
const GETID3_FLV_VIDEO_H263
+ 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.

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

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
162  case GETID3_FLV_TAG_META:
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  }
const GETID3_FLV_TAG_VIDEO
const GETID3_FLV_TAG_META
const GETID3_FLV_TAG_AUDIO
getID3() by James Heinrich info@getid3.org //
const GETID3_FLV_VIDEO_VP6
BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:234
+ Here is the call graph for this function:

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