swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] Question


From: Daichi Shinozaki
Subject: Re: [Swftools-common] Question
Date: Fri, 04 Feb 2005 01:07:00 +0900
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040616

Hi,

Christian Langis wrote:

What I currently do is take my SWF5 buffer, update the version tag from 5 to 6 and compress it all (past the first 8 bytes) using the "compress" function in the ZLIB. I does not work. The player (FlashPlayer7 plugin) would not show it.
Everything seems right.
I have a working sample in Perl, hope this helps.

        O         [swfcompressor.pl]
_________\/______ Please snip and save _____________________
         /\
        O
#!/usr/bin/perl -w
use strict;
use Compress::Zlib;

print "usage: swfcompress.pl <input file>\n"
  and exit unless $ARGV[0];

my ($size, $header, $raw_swf, $swf);
my $infile = shift @ARGV;

open(F, "< $infile") or die "Failed to open file: $infile [$!]\n";
binmode(F);
$size = -s F;
seek(F, 8, 1);    # skip first 8 bytes
$/ = undef;
$raw_swf = <F>; # read from byte 9 to eof
seek(F, 0, 0);
# check the header
read(F, $header, 3);
die "File is already compressed.\n" if substr($header, 0, 1) eq 'C';
die "Not a flash file.\n" if $header ne 'FWS';
read(F, $header, 1);
$header = int ord $header;
die "Flash version is wrong.\n" if $header >= 0x6 && $header <= 0x0;

$header = 'CWS' . pack 'CV', 6, $size;
$swf = compress($raw_swf);
close(F);
open(F_SWF, "> $infile")
  or die "Failed to open output file\n";
binmode(F_SWF);
print F_SWF $header, $swf;
____________________________________________________________

--
Daichi Shinozaki
SHIELD.JP Admin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]