I'm looking for a batch script to convert swf to mp4, lossless. I tried using both ffmpeg and handbrake, but apparently swf is compressed and I can't convert them this way.
ffmpeg -i input -c:v libx264 -preset ultrafast -qp 0 output.mkv
HandBrakeCLI -i source -o destination
I know I acn use a tool like xilisoft, but I've more than 3000 videos and would need to run this automatically. Is there a script/ algorithm that can help me automate this process?
You may use this script:
Works for me!
Get gnash:
You'll need a bunch of dependencies before you can build it (should be able to apt-get them all):
Then configure and build the gnash video dumper:
you can then point dump-gnash at a swf and it will render out the raw video and audio
This will write out
/tmp/out.raw
(which is bgra aka rgb32 video) at 30fps (the@30
bit) and/tmp/out.wav
These need re-combining into e.g. mp4 using:
because its raw video, ffmpeg needs to know colourspace (rga32) dimensions and input fps. We tell it to combine the audio (160kbps mp3), render the video back out at 30fps
You'll need additional flags to get the lossless mp4.
I don't exactly know if this is lossless but at least I got the convert part working(ffmpeg).
dependencies
Decompress
First I decompressed using swfcombine:
Convert
Next I converted using ffmpeg which might not be lossless with these parameters
I just would like to say that there is not reliable way to convert SWF to MP4. Because SWF-file is a program generally. In simplest case SWF-file contains only video (and audio as well). Solutions provided by jaygooby, Alfred and Aleksey Kontsevich work perfectly in such cases.
But many SWF-files contain theirs own Play/Pause buttons, volume controls, etc. When you open such file in Gnash (or whatever player) you need to perform additional action (for example, click on an embedded Play button) in order to really start playing. Yes, it's possible to automate this stuff in some way (e.g.
Xvfb
,xdotool
, etc). At the same time there are a lot of caveats there (especially audio stream). I even wrote an article about such approach (sorry, that's in Russian).PS1 Please do not consider this answer and the latter link as an advertisement of my site.
PS2 This stuff should go as comment. But it's published as answer because of text format.