PHP reads flash file height, width, frame number, background color code_PHP tutorial

WBOY
Release: 2016-07-20 11:09:39
Original
1014 people have browsed it

php tutorial to read flash file height, width, frame number, background color code

/*
Example:
$file = '/data/ad_files /5/5.swf';
$flash = new flash();
$flash = $flash->getswfinfo($file);
echo "
The width and height of the file are: ".$flash["width"].":".$info["height"];
echo "
The file version is".$flash["version"];
echo "
The number of file frames is ".$flash["framecount"];
echo "
The file frame rate is".$flash["framerate"];
echo "
The file background color is" .$flash["bgcolor"];
*/
class flash
{
// Whether to return the background color
public $need_back_color = false ;

// Whether Return version
public $need_version = false ;

//Whether to return frame rate
public $need_framerate = false ;

//Whether to return frame number
public $need_framecount = false ;

public function __construct()
{

}

public function getswfinfo( $filename )
{
if ( file_exists($ filename) ) {
//echo "File modification time:".date("m d y h:i:s.", filemtime($filename))."
";
} else {
             //echo "The target file does not exist!"; $filename,"r");

//Read file data

$str = fread( $rs, filesize( $filename ) ) ;

///
if( $str[0] == "f")
{
//echo "
The file is already a decompressed file:";
} else {
$first = substr($ str,0,8);
              $last = substr($str,8);                                                           first . $last ;
        $str[0] = "f";
         //echo "
Decompressed file information:";
   }

     $info = $this->getinfo( $str );
fclose ( $rs ) ;
return $info;
}

private function mydecbin($str,$index)
{
$fbin = decbin(ord($str[$index]));

while(strlen($fbin)<8)$fbin="0".$fbin;

return $fbin ;
}

private function colorhex($data)

{

$tmp = dechex($data);
if ( strlen($tmp)<2 ) {
       $tmp='0' . $tmp ;
    }
      return $tmp; Into binary
$fbin = $this->mydecbin( $str, 8) ;

//Calculate the unit length of rec
$slen = bindec( substr( $fbin, 0, 5 ) );

//Calculate the byte where rec is located
$recsize = $slen * 4 + 5;
$recsize = ceil( $recsize / 8);

//rec binary

$recbin = $fbin ;

for( $i = 9 ; $i < $recsize + 8 ; $i++ )
{
$recbin .= $this- >mydecbin( $str ,$i );
}

    //rec数据
    $rec = array();
    for( $i = 0 ; $i < 4 ; $i++ )
    {
       $rec[] = bindec( substr( $recbin , 5 + $i * $slen , $slen ) ) / 20 ;
    }
   
    if ( $this->need_back_color ) {
      //背景颜色
      for( $i = $recsize + 12 ; $i < strlen ( $str ) ; $i ++ )
      {
         if ( ord( $str[$i] ) == 67 && ord( $str[$i+1] ) == 2 )
         {
          $bgcolor = $this->colorhex(ord($str[$i+2])).$this->colorhex(ord($str[$i+3])).$this->colorhex(ord($str[$i+4]));
          break;
         }
      }
    }
   
    if ( $this->need_version ) {
      //版本
      $version = ord( $str[3] );
    }
    if ( $this->need_framerate ) {
      //帧速率
      $framerate = ord( $str[$recsize + 8] ) / 256 + ord( $str[$recsize + 9] ) ;
    }

    if ( $this->need_framecount ) {   
      //帧数量
      $framecount = ord( $str[$recsize + 11] ) * 256 + ord( $str[$recsize + 10] );
    }
   
    return  array ( "bgcolor" => $bgcolor ,
            "version" => $version ,
            "framerate" => $framerate ,
            "framecount" => $framecount ,
            'width'=>$rec[1],
            'height'=>$rec[3]
            );
  }
}

?>


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444786.htmlTechArticlephp教程读取flash文件高宽帧数背景颜色代码 ?php /* 示例: $file = '/data/ad_files/5/5.swf'; $flash = new flash(); $flash = $flash-getswfinfo($file); echo 文件的宽...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template