license.
[VideoToiPod.git] / main.command
blob4feeb30060cba3e31a22094c7418557bf818c4b6
1 #!/usr/bin/env sh
3 # main.command
4 # VideoToiPod
6 # Created by Pierre Andrews on 13/09/2007.
7 # Copyright 2007 Pierre Andrews. All rights reserved.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 if [[ ! "${overwrite}" ]]; then overwrite=0; fi
23 if [[ ! "${twopass}" ]]; then twopass=0; fi
24 case "${overwrite}" in
25 0) over= ;;
26 1) over=" -y ";;
27 esac
29 while read line; do
30 if [[ ! "${destdir}" ]]; then destdir=`dirname "$line"`; fi
31 output=`basename "${line}"`;
32 output=${output%\.*}
33 fullpath=`ksh -c "(cd "${destdir}" 2>/dev/null && /bin/pwd)"`
34 output="${fullpath}/${output}.mp4"
35 ffmpegpath=`dirname $0`
37 case "${twopass}" in
38 0) #1pass
39 $ffmpegpath/ffmpeg $over -i "${line}" -acodec aac -ab 90 -ac 2 -s 320x240 -vcodec h264 -b 768k -flags +loop -cmp +chroma -partitions +parti4x4+partp4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 7 -trellis 2 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 768k -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -f mp4 "${output}" 2>> /dev/console < /dev/null
40 errorFF=$?
42 1) #2pass
43 $ffmpegpath/ffmpeg -y -i "${line}" -passlogfile /tmp/ffmpeg_automator -an -pass 1 -s 320x240 -vcodec h264 -b 768k -flags +loop -cmp +chroma -partitions 0 -me epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 768k -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -f mp4 /dev/null 2>> /dev/console < /dev/null
44 errorFF=$?
45 $ffmpegpath/ffmpeg $over -i "${line}" -passlogfile /tmp/ffmpeg_automator -acodec aac -ab 90 -ar 48000 -ac 2 -pass 2 -s 320x240 -vcodec h264 -b 768k -flags +loop -cmp +chroma -partitions +parti4x4+partp4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me umh -subq 7 -trellis 2 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 768k -maxrate 768k -bufsize 2M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -f mp4 "${output}" 2>> /dev/console < /dev/null
46 errorFF=$?
47 if [ -r x264_2pass.log ]; then
48 rm x264_2pass.log;
50 if [ -r /tmp/ffmpeg_automator ]; then
51 rm /tmp/ffmpeg_automator;
54 esac
55 if [ $errorFF -eq 0 ]; then
56 echo "$output";
59 done