note 86430 deleted from faq by philip

From: Date: Sun, 22 Feb 2009 21:20:43 +0000
Subject: note 86430 deleted from faq by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150975@lists.php.net to get a copy of this message
Note Submitter: jbrnra at gmail dot com ---- It is sometimes useful to decompressed SWF files, for example if you want to process it usin ffmpeg. I wrote this function because I didn't want to call en external program (like cws2fws) <?php /** * convert compressed swf to uncompressed. usefull for ffmpeg usage * @param string $in_swf_file input file to convert * @param string $out_swf_file converted output file * @param string $error error message * @return boolean true or false * see more info at http://the-labs.com/MacromediaFlash/SWF-Spec/SWFfileformat.html * and a perl version at http://zefonseca.com/cws2fws/release/cws2fws */ function decode_swf($in_swf_file, $out_swf_file, &$error) { $swf = file_get_contents($in_swf_file); // read entire file if (!$swf) { $error = "SWF file not fount - $in_swf_file"; return FAIL; } $type = substr($swf, 0, 3); // already in uncompressed format? if ($type == 'FWS') { @copy ($in_swf_file, $out_swf_file); return SUCCESS; } if ($type != 'CWS') { $error = "Wrong file format - $in_swf_file"; return FAIL; } $uncomp = gzuncompress (substr($swf, 8)); // unzip everything but the header if (!$uncomp) { $error = "File data error - $in_swf_file"; return FAIL; } $header = substr($swf, 0, 8); $header[0] = 'F'; // CWS -> FWS $status = file_put_contents($out_swf_file , $header . $uncomp); if (!$status) { $error = "File write error - $out_swf_file"; return FAIL; } return SUCCESS; } ?>

« previous php.notes (#150975) next »