[swfmill] newbie: creating animation from a series of jpg files various timings

Nils Millahn nils at hub124.co.uk
Mon Mar 5 14:25:14 EST 2007


I've just skimmed over this but it occurred to me that you could simply 
set the framerate of the SWF to that of the frame-grabber, in which case 
the millisecond values should correspond exactly to frames in the SWF. 
That approach would remove any rounding issues you may have at the moment...


Jon Molesa wrote:
> I only skimmed this, but it may be useful to you.  More so than my
> explaination
>
> http://www.science.uva.nl/ict/ossdocs/java/tutorial/ui/drawing/animLoop.html
>
> It talks about an animation loop.  Appears to be java or js, but that's
> close enough to AS to gleen something useful maybe.
>
> * Seth Markowitz <seth.markowitz at gmail.com> wrote:
>
>   
>> On 3/5/07, Jon Molesa <rjmolesa at consoltec.net> wrote:
>>     
>>> Nice solution to a problem.  Mind if I include this in the wip
>>> documentation as an example?
>>>       
>>
>> what is the "wip" documentation? -- sure.. you can use the example in the
>> doc.
>>
>>
>> In either case, your issue isn't so much with swfmill as it is a
>>     
>>> mathematical conversion from ms to fps.  Is that a correct assessment?
>>>       
>>
>> You're absolutely right.  The real question here is what is a good formula
>> for converting milliseconds to frames.  Right now I'm doing this in my perl
>> script:
>>
>> $fps = 15;
>> $frameNum = int($millisecondTimeStamp/1000 * $fps);
>>
>>
>>
>> My first thought is to decide on a fps rate that you'd like to have.
>>     
>>> Then there _could_ be total of 1000 fps with the framegrabber. A fps of
>>> 12 fps is a good speed for the human eye I believe?? Double check on that.
>>> You'd have to figure out which block the captured frame fell into and
>>> place it
>>> in that frame.  On a 12 second frame rate, 1 frame would contain
>>> 83.33ms.  So you'd just have to figure out what which block the captured
>>> frame fell into.  swfmill frame second1-frame1~=84ms,
>>> second1-frame2~=168ms... and so on.
>>> It's too early to come up with a formula, but maybe later, or maybe
>>> someone else can develop that.  Anyway, I hope it helps and is close to
>>> correct.  But that's the way I see it.
>>>
>>> * Seth Markowitz <seth.markowitz at gmail.com> wrote:
>>>
>>>       
>>>> Hi,
>>>>
>>>> I'm a newbie to swfmill, but I did get it working for my purposes... I'm
>>>> just trying to figure out how to make it more efficient.  Here is my
>>>> situation:
>>>>
>>>> Here's my inventory:
>>>> 1. I have 1000 jpg images taken from a vga frame grabber - NOT in frames
>>>>         
>>> per
>>>       
>>>> second... the timing is variable.  For example, file1.jpg was grabbed at
>>>> 30ms, file2.jpg was grabbed at 400ms, file3.jpg at 410ms, an so on. The
>>>>         
>>> time
>>>       
>>>> starts from Time == 0ms when the frame grabber was turned on.
>>>>
>>>> 2. I have an XML file called capture.xml  that contains the timestamp in
>>>> milliseconds for when each jpg was captured:
>>>>
>>>>    <Capture>
>>>>      <FileName>Slide_0020.jpg</FileName>
>>>>      <SlideNumber>20</SlideNumber>
>>>>      <CaptureTime>64174</CaptureTime>
>>>>    </Capture>
>>>>    <Capture>
>>>>      <FileName>Slide_0021.jpg</FileName>
>>>>      <SlideNumber>21</SlideNumber>
>>>>      <CaptureTime>64869</CaptureTime>
>>>>    </Capture>
>>>>
>>>> So....
>>>> By putting all the jpg files together into a SWF via swfmill, I should
>>>>         
>>> have
>>>       
>>>> a fairly descent "flipbook" type animation.  I've created a perl script
>>>>         
>>> to
>>>       
>>>> parse the capture.xml file and creates a swfml file that looks like
>>>>         
>>> this:
>>>       
>>>> <?xml version="1.0" encoding="iso-8859-1" ?>
>>>> <movie width="640" height="480" framerate="15">
>>>>  <background color="#ffffff"/>
>>>> <frame>
>>>>    <!-- frame:0  ptime:54 -->
>>>>    <library>
>>>>        <clip id="image1" import="Slide_0001_Full_resize.jpg" />
>>>>    </library>
>>>>    <place id="image1" name="myImage1" x="0" y="0" depth="1" />
>>>> </frame>
>>>> <frame/><frame/><frame/><frame/><frame/><frame/><frame>
>>>>    <!-- frame:6  ptime:408 -->
>>>>    <library>
>>>>        <clip id="image2" import="Slide_0002_Full_resize.jpg" />
>>>>    </library>
>>>>    <place id="image2" name="myImage2" x="0" y="0" depth="2" />
>>>> </frame>
>>>> <frame/><frame/><frame/><frame/><frame/><frame>
>>>>    <!-- frame:11  ptime:752 -->
>>>>    <library>
>>>>        <clip id="image3" import="Slide_0003_Full_resize.jpg" />
>>>>    </library>
>>>>    <place id="image3" name="myImage3" x="0" y="0" depth="3" />
>>>> </frame>
>>>>
>>>> .....
>>>>
>>>> Right now this is klunky because I'm trying to convert the millisecond
>>>> timestamp into frames per second.  For example, if I want to run this
>>>> animation at 10fps, I know that the jpg captured at 100ms will appear in
>>>> frame 1 and so on (is that right??).  So what happens in between each
>>>> frame... if  file1.jpg is captures at 10seconds before file2.jpg, I just
>>>> stick (10x10) 100 <frame /> tags as filler in between the two
>>>>         
>>> images.  There
>>>       
>>>> must be a better way than this.  Also, since I'm converting from
>>>> milliseconds to frames per second... I think I'm losing a lot of
>>>>         
>>> precision.
>>>       
>>>> How could I create this "flipbook" effect, given the inventory above
>>>>         
>>> using
>>>       
>>>> swfmill simple?
>>>>
>>>> I think this is a pretty interesting problem and I really wanted to
>>>>         
>>> thank
>>>       
>>>> the creators of swfmill... it's a great solution to this type of
>>>>         
>>> thing.  I
>>>       
>>>> was orginally trying to create an AVI file from this series of jpg
>>>>         
>>> files,
>>>       
>>>> but it got way too complicated for me.
>>>>
>>>> Looking forward to some suggestions!!
>>>>
>>>> Seth
>>>>         
>>>> _______________________________________________
>>>> swfmill mailing list
>>>> swfmill at osflash.org
>>>> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>>>         
>>> --
>>> Jon Molesa
>>> rjmolesa at consoltec.net
>>>
>>> _______________________________________________
>>> swfmill mailing list
>>> swfmill at osflash.org
>>> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>>
>>>       
>
>   
>> _______________________________________________
>> swfmill mailing list
>> swfmill at osflash.org
>> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>     
>
>
>   

-- 
-----------------------------------------------------------------------
Nils Millahn
Internet Solutions - Design and Development - Flash Specialist

T: +44 (0) 7909 528 617
E: nils at hub124.co.uk
W: www.hub124.co.uk

=======================================================================
Notice of Confidentiality.

This transmission is intended for the named recipient only. It contains information which may be confidential and which may also be privileged. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else.

It is the responsibility of the recipient to ensure that the forwarding, opening or use of the e-mail (and any attachment) will not adversely
affect their system or data. Please carry out appropriate virus checks.
=======================================================================




More information about the swfmill mailing list