IPadConversion

From FrogspawnWiki

Jump to: navigation, search

This is a simple enough shell script to convert an input video file into something that can be played back on an iPad and presumably also on other mp4 playing devices. It consists of two things, there's a shell script that does the heavy lifting and a ffmpeg preset that has the format and encoding options for ffmpeg.


Shell Script

Simple script, takes one argument (the filename to convert), it then works out the new filename by lopping the current extension off and replacing it with .mp4. It creates an iPad directory if one doesn't already exist in the current directory and then converts the file using ffmpeg. It times the conversion because it's a nice-to-know.

inputfile=$1
outputfile=${inputfile%\.*}.mp4
 
if [ ! -d iPad ]
then mkdir iPad
fi
 
echo "\n\n\nConverting $inputfile to iPad format\n"
time ffmpeg -s 640x360 -r 30 -async 2 -aspect 16:9 -y -i "$inputfile" -fpre /usr/share/ffmpeg/iPad.ffpreset -strict experimental "iPad/$outputfile"


Preset

The preset /usr/share/ffmpeg/iPad.ffpreset consists of the following:

threads=4
acodec=aac
ar=48000
ab=128k
ac=2
vcodec=libx264
b=1200k
flags=+loop+mv4
cmp=+chroma
#partitions=+parti4×4+partp8×8+partb8×8
subq=7
trellis=1
refs=5
coder=0
me_range=16
keyint_min=25
bt=256k
maxrate=10000k
sc_threshold=40
i_qfactor=0.71
qdiff=4
level=30
g=250

I'll admit that it doesn't mean a lot to me, mostly scavenged from online resources that I can't remember now, but most of it you can work out.

Personal tools