43 $info = &$this->getid3->info;
45 $info[
'fileformat'] =
'swf';
46 $info[
'video'][
'dataformat'] =
'swf';
50 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
52 $SWFfileData =
fread($this->getid3->fp,
$info[
'avdataend'] -
$info[
'avdataoffset']);
54 $info[
'swf'][
'header'][
'signature'] = substr($SWFfileData, 0, 3);
55 switch (
$info[
'swf'][
'header'][
'signature']) {
57 $info[
'swf'][
'header'][
'compressed'] =
false;
61 $info[
'swf'][
'header'][
'compressed'] =
true;
65 $info[
'error'][] =
'Expecting "FWS" or "CWS" at offset '.$info[
'avdataoffset'].
', found "'.
Helper::PrintHexBytes(
$info[
'swf'][
'header'][
'signature']).
'"';
67 unset(
$info[
'fileformat']);
75 if (
$info[
'swf'][
'header'][
'compressed']) {
76 $SWFHead = substr($SWFfileData, 0, 8);
77 $SWFfileData = substr($SWFfileData, 8);
78 if ($decompressed = @gzuncompress($SWFfileData)) {
79 $SWFfileData = $SWFHead.$decompressed;
81 $info[
'error'][] =
'Error decompressing compressed SWF data ('.strlen($SWFfileData).
' bytes compressed, should be '.(
$info[
'swf'][
'header'][
'length'] - 8).
' bytes uncompressed)';
87 $FrameSizeBitsPerValue = (ord(substr($SWFfileData, 8, 1)) & 0xF8) >> 3;
88 $FrameSizeDataLength = ceil((5 + (4 * $FrameSizeBitsPerValue)) / 8);
89 $FrameSizeDataString = str_pad(decbin(ord(substr($SWFfileData, 8, 1)) & 0x07), 3,
'0', STR_PAD_LEFT);
90 for ($i = 1; $i < $FrameSizeDataLength; $i++) {
91 $FrameSizeDataString .= str_pad(decbin(ord(substr($SWFfileData, 8 + $i, 1))), 8,
'0', STR_PAD_LEFT);
93 list($X1, $X2, $Y1, $Y2) = explode(
"\n", wordwrap($FrameSizeDataString, $FrameSizeBitsPerValue,
"\n", 1));
107 $info[
'video'][
'frame_rate'] =
$info[
'swf'][
'header'][
'frame_rate'];
108 $info[
'video'][
'resolution_x'] = intval(round(
$info[
'swf'][
'header'][
'frame_width'] / 20));
109 $info[
'video'][
'resolution_y'] = intval(round(
$info[
'swf'][
'header'][
'frame_height'] / 20));
110 $info[
'video'][
'pixel_aspect_ratio'] = (float) 1;
112 if ((
$info[
'swf'][
'header'][
'frame_count'] > 0) && (
$info[
'swf'][
'header'][
'frame_rate'] > 0)) {
113 $info[
'playtime_seconds'] =
$info[
'swf'][
'header'][
'frame_count'] /
$info[
'swf'][
'header'][
'frame_rate'];
119 $CurrentOffset = 12 + $FrameSizeDataLength;
120 $SWFdataLength = strlen($SWFfileData);
122 while ($CurrentOffset < $SWFdataLength) {
126 $TagID = ($TagIDTagLength & 0xFFFC) >> 6;
127 $TagLength = ($TagIDTagLength & 0x003F);
129 if ($TagLength == 0x3F) {
135 $TagData[
'offset'] = $CurrentOffset;
136 $TagData[
'size'] = $TagLength;
137 $TagData[
'id'] = $TagID;
138 $TagData[
'data'] = substr($SWFfileData, $CurrentOffset, $TagLength);
149 if ($this->ReturnAllTagData) {
150 $info[
'swf'][
'tags'][] = $TagData;
155 $CurrentOffset += $TagLength;
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
fseek($bytes, $whence=SEEK_SET)
static LittleEndian2Int($byteword, $signed=false)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
static Bin2Dec($binstring, $signed=false)