3 # Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
5 # This script transcodes all input videos with a specified extension to a new
6 # format with a given resolutin and video bitrate. The audio bitrate is hard
7 # coded to 192 kb/s. The output_path parameter is optional. If not given it
8 # puts all output files in the same folder as the corresponding input.
11 if test $# -lt 4; then
12 echo "Usage: $0 input-path input-extension output-format resolution video-bitrate [output-suffix] [output_path]"
21 if [ ! -z "$6" ]; then
26 if [ ! -z "$7" ]; then
30 FFMPEG=/usr/bin/ffmpeg
35 for filename in $(find "$in_path" -name "*.$in_ext"); do
36 if [ ! -z "$out_path" ]; then
37 new_filename="${out_path}"$(basename "$filename" ."$in_ext")"$out_suffix"."$out_format"
39 new_filename=$(dirname "$filename")/$(basename "$filename" ."$in_ext")"$out_suffix"."$out_format"
42 if [ -e $new_filename ]; then
43 echo "$0: $new_filename already exists" >&2
49 $FFMPEG -i "$filename" -f avi -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
52 $FFMPEG -i "$filename" -f flv -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
55 $FFMPEG -i "$filename" -f mp4 -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s "$resolution" -threads 0 "$new_filename"
58 $FFMPEG -i "$filename" -f ogg -acodec libvorbis -ab $ABITRATE -ar 44100 -ac 2 -vcodec libtheora -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
61 $FFMPEG -i "$filename" -f webm -acodec libvorbis -ab $ABITRATE -ar 44100 -ac 2 -vcodec libvpx -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
64 $FFMPEG -i "$filename" -f mpegts -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
68 echo "Format $out_format is not implemented!" 1>&2