#!/bin/bash # # recode and burn subtitles for iphone/ipod-touch # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # (C) 2008 Jose L. Hidalgo ValiƱo (pplux@pplux.com) # [ -f "$1" ] || { echo "File $1, not found"; exit 1; } OUTPUT="i_${1%%${1##*.}}mp4" SUBS_FILE="${1%%${1##*.}}srt" SUBS_OPTS="" [ -f $SUBS_FILE ] && SUBS_OPTS="-subfont-autoscale 1 -sub $SUBS_FILE" && echo "Subtitles found..." # Create a temp file TEMP=$(mktemp) # first pass, rescale and include subtitles mencoder -vf scale=480:-3 -ovc lavc -oac copy $SUBS_OPTS -o $TEMP "$1" # encode using mpeg4 FFMPEG_VIDEO_OPTS="-vcodec libx264 -b 128k -level 30 -mbd 2 -cmp 2 -subcmp 2 -g 300 -qmin 20 -qmax 31 -flags +loop -chroma 1 -partitions partp8x8+partb8x8 -flags2 +mixed_refs -me_method 8 -subq 7 -trellis 2 -refs 1 -coder 0 -me_range 16 -bf 0 -sc_threshold 40 -keyint_min 25 -maxrate 3584k -bufsize 8192k" FFMPEG_AUDIO_OPTS="-acodec libfaac -ac 2 -ar 44100 -ab 0 -aq 120 -alang ENG -async 1 " ffmpeg -i $TEMP -y $FFMPEG_VIDEO_OPTS $FFMPEG_AUDIO_OPTS "${OUTPUT}" # remove temp file rm $TEMP echo "->$OUTPUT<- done!"