swftools-common
[Top][All Lists]
Advanced

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

Re: [Swftools-common] Cannon extract images using swfextract


From: Markus Stumpf
Subject: Re: [Swftools-common] Cannon extract images using swfextract
Date: Wed, 14 Jan 2009 08:12:07 +0100
User-agent: Mutt/1.4.2.3i

Hi

I have just subscribed, so bear with me please ;-)

Regarding the problem extracting JPEGs from swf files, here is what I
have found out (had the same problem)

The SWF is a "Macromedia Flash data (compressed), version 7" according
to "file" command.

The problem lies in the JPEG identifier. The JPEGs in the swf don't have
the marker
    0xff 0xd9 x0ff 0xd8
but
    0xff 0xd8 0xff 0xe0
and so the JPEG file is never found (no error as there was a simple "return"
for that case in the code).

So I modified swfextract.c:findjpegboundary() and added

        if(data[t  ]==0xff &&
           data[t+1]==0xd8 &&
           data[t+2]==0xff &&
           data[t+3]==0xe0) {
            pos = t;
        }

(oh, btw, the "pos" variable isn't needed IMHO. Instead of
    "pos = t"           use     "return pos"
and at the end of the function replace
    "return pos"        with    "return(-1)"
)

Also the code in swfextract.c:handlejpeg() didn't work for me.
I don't know anything about swf, so I probably don't understand
why there are 2 fwrite()s and what exactly is goind on there.

However, if I change the code to
(for ST_DEFINEBITSJPEG2)
            // fwrite(&tag->data[2], pos-2, 1, fi);
            // fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
            msg("<verbose> JPEG start is at pos %d", pos);
            msg("<verbose> JPEG size  is %d", end);
            fwrite(&tag->data[pos], end, 1, fi);

(for ST_DEFINEBITSJPEG3; also output error if pos<0)
        if(pos<0) {
            fprintf(stderr, "No JPEG picture indicator found\n");
            return;
        }
        pos+=6;
        fi = save_fopen(filename, "wb");
        // fwrite(&tag->data[6], pos-6, 1, fi);
        // fwrite(&tag->data[pos+4], end-(pos+4), 1, fi);
        msg("<verbose> JPEG start is at pos %d", pos);
        msg("<verbose> JPEG size  is %d", end);
        fwrite(&tag->data[pos], end, 1, fi);

all works fine for me.

Hope that helps.

        \Maex

-- 
Markus Stumpf




reply via email to

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