Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- BITRATE=300k
- SOURCE=$1
- TARGET=$2
- if [ $# -lt 2 ]; then
- echo "usage: $(basename $0) <input> <output>"
- exit 1
- fi
- while getopts "b:t:h" flag
- do
- case $flag in
- b )
- BITRATE="$OPTARG"
- ;;
- t )
- THREADS="$OPTARG"
- ;;
- h )
- echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
- echo " -b Specify the Bitrate. Should be between 200k and 1500k."
- echo " Note: The \"k\" is needed. e.g. \"512k\""
- echo " -h help (this help message)"
- echo " -t Specify the number of threads. This will default to the number of CPUS found."
- echo ""
- echo "example: `basename $0` -b 512k -t 2 some_video_file.avi target_video_file.mp4"
- exit 1
- ;;
- \? )
- echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
- echo "Use \"`basename $0` -h\" for more information"
- exit 1
- ;;
- * )
- echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
- echo "Use \"`basename $0` -h\" for more information"
- exit 1
- ;;
- esac
- done
- shift $(($OPTIND - 1))
- if [ -z "$BITRATE" ]
- then
- BITRATE=300k
- fi
- if [ -z "$THREADS" ]
- then
- THREADS=$(grep -c "^processor" /proc/cpuinfo)
- fi
- if [ -e ./.CONVERTED ]
- then
- echo "CONVERTED FILE Found"
- echo 'This has probably already been converted!'
- exit 1
- fi
- #Pass 1
- ffmpeg -threads $THREADS -y -i "$SOURCE" -s 480x272 -vcodec libx264 -b $BITRATE -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 \
- -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bt $BITRATE -maxrate 4M -bufsize 4M \
- -level 21 -r 30000/1001 -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -f mp41 -aspect 480:272 -acodec libfaac -ac 2 -ar 48000 -ab 128k -pass 1 "$TARGET"
- #Pass 2
- ffmpeg -threads $THREADS -y -i "$SOURCE" -s 480x272 -vcodec libx264 -b $BITRATE -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 \
- -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bt $BITRATE -maxrate 4M -bufsize 4M \
- -level 21 -r 30000/1001 -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -f mp41 -aspect 480:272 -pass 2 -acodec libfaac -ac 2 -ar 48000 -ab 128k -vol 320 "$TARGET"
- if [ $? -eq 0 ]
- then
- touch .CONVERTED
- fi
- # Clean up any temporary logs created by ffmpeg
- rm -f *log
- rm -f *dump
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement