batch convert MOV files to mp4

 If like me you prefer to not have any MOV files due to their size, you want to convert them to mp4 video.


#!/bin/sh


# -r = frame rate

# -f = output format

# -i = input file name

# -s = aspect ratio/frame size

# -crf = constant rate factor

# -pix_fmt yuv420p = quicktime compatible


quality=""

if [ "$1" == "-d" ] ; then

echo "Downscaling quality to 480x360 at 15fps"

quality="-r 20 -s 480x360"

fi

if [ "$1" == "-i" ] ; then

echo "Downscaling for old iphone and similar"

# for i in `/bin/ls` ; do ( echo $i ; ffmpeg -i $i -threads 0 -strict experimental -f mp4 -vcodec libx264 -vpre slow -vpre ipod640 -b 1200k -acodec aac -ab 160000 -ac 2 -s 480x320 iphone-$i ) ; done

quality="-vpre slow -vpre ipod640 -b 1200k -acodec aac -ab 160000 -ac 2 -s 480x320"

fi


for i in `/bin/ls | grep .[mM][oO][vV]` ; do (

echo "Converting QuickTime file to MP4: "$i

nn=`echo $i | sed -e s/\.[Mm][Oo][vV]/\.mp4/g`

# echo ffmpeg -i $i -strict experimental -vcodec libx264 -acodec aac -ab 160000 -ac 2 -vpre slow -crf $quality -f mp4 $nn

ffmpeg -i $i -f mp4 -vcodec libx264 -strict experimental -acodec aac $nn

) ; done


for i in `/bin/ls | grep .[aA][Vv][iI]` ; do (

        echo "Converting AVI to MP4: "$i

        nn=`echo $i | sed -e s/\.[aA][vV][iI]/\.mp4/g`

        # ffmpeg -i $i -strict experimental -vcodec libx264 -acodec aac -ab 160000 -ac 2 -vpre slow -crf $quality -f mp4 $nn

ffmpeg -i $i -f mp4 -vcodec libx264 -strict experimental -acodec aac $nn

) ; done


Popular posts from this blog

The most useful defaults-write options

Erasing firmware password

Migrating from Windows to Mac