Reputation: 32945
I have a large number of flash movies which i need to convert to mp4 files, to make them ios compatible. Each of the movies already has a basic html file (all called index.html) which will open the swf, setting the appropriate parameters to make it go.
Each video has the same format: the movie itself is 800px wide by 600px high. The bottom 60 px is taken up with a control bar with play button, scrubbber etc. I do not want to capture this (since the mp4 player will add its own controls): i only want to capture the top 540px. Each flash video has an xml file which it reads in, and i can scrape the duration of the flash movie from this, so that i can pass the duration of the movie to whatever does the recording.
I'm in linux, and I want to write a script which does the following:
Let's say, as an example, that for the first video i have these parameters i can pass through to whatever tool is going to do this:
{url: "localhost:3000/my_video_input/1/index.html", duration: 250, output_file:"/home/max/my_video_output/1/video.mp4"}
Can anyone point me at a tool, or perhaps a javascript library, for doing this? Perhaps the solution involves writing javascript into the html file before loading it into the browser. If so then that's doable but i'd prefer something simpler :)
thanks in advance - max
EDIT - some more info. The flash apps are as2, not as3, in case that's relevant.
Upvotes: 1
Views: 1855
Reputation: 2536
Get gnash:
git clone git://git.sv.gnu.org/gnash.git
You'll need a bunch of dependencies before you can build it (should be able to apt-get them all):
libsdl libboost libagg
Then configure and build the gnash (open source flash player) video dumper:
cd gnash
./autogen.sh
./configure --enable-renderer=agg \
--enable-gui=dump \
--disable-menus \
--enable-media=ffmpeg \
--disable-jemalloc
make
then you can point dump-gnash
at a swf and it will render out the raw video and audio
dump-gnash -1 \
-D /tmp/out.raw@30 \
-A /tmp/out.wav \
-P "FlashVars=myURL=http://example.com/blah&online=true" \
http://example.com/blah/some.swf
This will write out /tmp/out.raw
(which is bgra aka rgb32 video) at 30fps (the @30 bit) and /tmp/out.wav
(the audio track).
These need re-combining into e.g. mp4 using:
ffmpeg -i /tmp/out.wav \
-f rawvideo \
-pix_fmt rgb32 \
-s:v 800x550 \
-r 30 \
-i /tmp/out \
-c:v libx264 \
-r 30 \
-b 160k \
/tmp/out.mp4
because it's raw video, ffmpeg needs to know the colourspace (rgb32), dimensions and input fps. We tell it to combine the audio (160kbps mp3), render the video back out at 30fps.
Upvotes: 3
Reputation: 1202
I'm going to assume by 'Flash Movies' you mean Flash animations which are controlled by a playhead, rather than FLV video files which are controlled by a playhead.
I doubt JavaScript will be able to do this. In my experience, if you want to read SWF content (specifically capturing SWF image content), the easiest way is with a container Flash script/app.
This answer will explain how to take a loaded Flash and capture image data from it (you'll need Flash Professional to implement this solution. The free trial should accommodate you here).
You will be able to specify the dimensions which are being captured. See the Adobe reference on BitmapData for more information.
You will need to control the animation to give your capturer script time to read/write the data. Thankfully because you are using Flash/SWFLoader you can read the number of frames in the loaded Flash, and also control the playback.
Then, output uncompressed video from the BitmapData series, which is addressed in this answer.
I will assume you have access to a tool which will take an entire folder of uncompressed videos and convert them to a different format. If not, there are plenty of free and commercial programs available for this and they will be your best method for this task (rather than writing a video encoding script in Flash yourself which I assure you won't be easy)
If your files are hosted on the web, a client-side language (JavaScript) will be of no use to you. You will need a server-side language (PHP for instance) to collect all of the file locations and display them for the client.
I advise writing a PHP script which makes an XML file which lists all of the SWF locations in a folder (and all subdirectories), and have Flash read that generated XML file so that it knows which URLs to call. I suggest you raise a separate question if you need help with that.
Upvotes: 1