Created
November 11, 2021 11:05
-
-
Save andre-st/109e7661f0822b8c6e82e149cba79218 to your computer and use it in GitHub Desktop.
Convert Flash SWF files to MP4 using Linux ffmpeg and GNU Gnash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires: | |
# - ffmpeg | |
# - GNU Gnash: | |
# $ git clone git://git.sv.gnu.org/gnash.git | |
# $ cd gnash | |
# $ ./autogen.sh | |
# $ ./configure --enable-renderer=agg --enable-gui=dump --disable-menus --enable-media=ffmpeg --disable-jemalloc | |
# $ make > /dev/null | |
# $ make install | |
SWFFILE=$1 | |
MP4FILE=${SWFFILE%.*}.mp4 | |
TMPRAW=$(mktemp -t raw.XXXXXX) | |
TMPWAV=$(mktemp -t wav.XXXXXX) | |
# create raw-dump | |
GNASHCMD="dump-gnash -1 -r 3 -v -D $TMPRAW -A $TMPWAV $SWFFILE" | |
GNASHOUT="$(exec $GNASHCMD)" | |
# extract parameters | |
WIDTH="$(echo $GNASHOUT | grep -o 'WIDTH=[^, }]*' | sed 's/^.*=//')" | |
HEIGHT="$(echo $GNASHOUT | grep -o 'HEIGHT=[^, }]*' | sed 's/^.*=//')" | |
FPS="$(echo $GNASHOUT | grep -o 'FPS_ACTUAL=[^, }]*' | sed 's/^.*=//')" | |
# Convert | |
ffmpeg \ | |
-i "${TMPWAV}" -f rawvideo -pix_fmt rgb32 -s:v ${WIDTH}x${HEIGHT} -r ${FPS} \ | |
-i "${TMPRAW}" -c:v libx264 -r 30 -b 160k \ | |
"${MP4FILE}" | |
# clean up | |
rm -rf "${TMPRAW}" | |
rm -rf "${TMPWAV}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment