Created
August 8, 2017 20:28
-
-
Save ronoaldo/9c5b8fdadaec71305c4cfd830270de35 to your computer and use it in GitHub Desktop.
Converte SWF para MP4
This file contains hidden or 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 | |
echo "swf2mp4.sh - flash player to mp4 conversion script" | |
echo " * Requires gnash, mplayer2 and ffmpeg CLI tools" | |
echo " * Source https://stackoverflow.com/a/39304421 (Aleksey Kontsevich)" | |
SWFFILE=$1 | |
MP4FILE=${SWFFILE%.*}.mp4 | |
TMPFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).bin | |
TMPWAV=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).wav | |
TMPMP4=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).mp4 | |
# create raw-dump | |
GNASHCMD="dump-gnash -1 -r 3 -v -D $TMPFILE -A $TMPWAV $SWFFILE" | |
OUTPUT="$(exec $GNASHCMD)" | |
# extract parameters | |
WIDTH="$(echo $OUTPUT | grep -o 'WIDTH=[^, }]*' | sed 's/^.*=//')" | |
HEIGHT="$(echo $OUTPUT | grep -o 'HEIGHT=[^, }]*' | sed 's/^.*=//')" | |
FPS="$(echo $OUTPUT | grep -o 'FPS_ACTUAL=[^, }]*' | sed 's/^.*=//')" | |
# create raw, uncompressed mp4 file | |
mplayer $TMPFILE -vo yuv4mpeg:file=$TMPMP4 -demuxer rawvideo -rawvideo fps=$FPS:w=$WIDTH:h=$HEIGHT:format=bgra | |
# create compressed mp4 with ffmpeg | |
ffmpeg -i $TMPMP4 -i $TMPWAV $MP4FILE | |
# clean up | |
rm -rf $TMPFILE | |
rm -rf $TMPMP4 | |
rm -rf $TMPWAV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment