How to Convert SWF to MP4 with FFmpeg

This article provides a quick guide on how to convert vector-based Shockwave Flash (SWF) animations into MP4 videos using the command-line tool FFmpeg. While FFmpeg can easily process SWF files containing standard embedded video streams, vector-based animations with interactive ActionScript require specific arguments to render correctly. Below, you will find the exact commands and configurations needed to perform this conversion efficiently.

The Basic Conversion Command

If your SWF file consists of standard frame-by-frame vector animations without complex interactive scripts, FFmpeg can render and convert it directly. Open your terminal or command prompt and run the following command:

ffmpeg -i input.swf -c:v libx264 -r 30 -pix_fmt yuv420p output.mp4

Command Breakdown

Handling Audio Streams

If your SWF file contains audio, you should map and transcode the audio to AAC (the standard audio format for MP4) to ensure it plays correctly:

ffmpeg -i input.swf -c:v libx264 -c:a aac -b:a 192k -r 30 -pix_fmt yuv420p output.mp4

Limitations with Interactive ActionScript

FFmpeg’s built-in SWF decoder reads the static timeline of the Flash file. If your SWF relies heavily on complex ActionScript, nested movie clips that play independently of the main timeline, or user interaction (like button clicks), FFmpeg will not be able to execute the code.

For highly interactive vector SWFs, the recommended workaround is to play the SWF using a modern Flash player emulator like Ruffle or the standalone Adobe Flash Player projector, capture the screen using FFmpeg’s screen-grabbing utility (such as gdigrab on Windows or x11grab on Linux), and output that capture directly to an MP4 file.