note 86430 added to faq

From: Date: Sat, 18 Oct 2008 14:13:53 +0000
Subject: note 86430 added to faq
Groups: php.notes 
Request: Send a blank email to php-notes+get-145469@lists.php.net to get a copy of this message
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) /** * 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; } ---- Server IP: 212.199.163.191 Probable Submitter: 84.228.200.228 ---- Manual Page -- http://www.php.net/manual/en/faq.php Edit -- https://master.php.net/note/edit/86430 Del: integrated -- https://master.php.net/note/delete/86430/integrated Del: useless -- https://master.php.net/note/delete/86430/useless Del: bad code -- https://master.php.net/note/delete/86430/bad+code Del: spam -- https://master.php.net/note/delete/86430/spam Del: non-english -- https://master.php.net/note/delete/86430/non-english Del: in docs -- https://master.php.net/note/delete/86430/in+docs Del: other reasons-- https://master.php.net/note/delete/86430 Reject -- https://master.php.net/note/reject/86430 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145469) next »