Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert swf file to mp4 using ffmpeg

I need to convert swf files to mp4 files using ffmpeg commands (command line). There is text in swf files which must be converted too. But when I convert files using the following ffmpeg command text in swf file is not converted to mp4 / no text is visible in mp4 file:

ffmpeg -i file.swf video.mp4

Is there any other command to convert text?

like image 610
Hussnain Avatar asked Oct 15 '15 14:10

Hussnain


1 Answers

I had the same problem. My walk around was to use the raw-output of gnash.

The following bash script summarizes the single steps.

#!/bin/bash

SWFFILE=$1
MP4FILE=${SWFFILE%.*}.mp4
TMPFILE=/tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).bin
TMPMP4=/tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).mp4

# create raw-dump
GNASHCMD="dump-gnash -1 -r 1 -D $TMPFILE $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 (ffmpeg should work as well)
avconv -i $TMPMP4 $MP4FILE

# clean up
rm -rf $TMPFILE
rm -rf $TMPMP4
like image 153
skn Avatar answered Sep 20 '22 08:09

skn