Files
videoweb/scripts/convert-videos.sh

29 lines
951 B
Bash
Raw Normal View History

#! /bin/bash -ex
SRC=${1:-.}
DST=${2:-/var/tmp/spielfilme}
declare -A FLAGS
2016-02-23 17:43:10 +00:00
FORMATS=( "ogg" "webm" "mp4" )
FLAGS["ogg"]="-c:v libtheora -c:a libvorbis -q:v 6 -q:a 5"
FLAGS["webm"]="-vcodec libvpx -acodec libvorbis -f webm -aq 5 -ac 2 -qmax 25 -threads 2"
FLAGS["mp4"]="-vcodec libx264 -acodec aac -strict experimental -crf 19"
for f in $(find "$SRC" \( \( -name '.??*' -o -name '*.jpg' \) -prune \) -o -type f -print); do
2016-02-23 17:43:10 +00:00
for format in "${FORMATS[@]}"; do
t="${f/$SRC/$DST}"
t="${t%.*}.${format}"
if test -s "${t}"; then
2015-03-31 13:59:17 +00:00
continue; # ignore if file exists and is not empty
fi
2015-03-31 13:59:17 +00:00
if test -e "$t"; then
rm "$t"; # remove existing empty file
fi
test -d "${t%/*}" || mkdir -p "${t%/*}"
2016-02-23 17:43:10 +00:00
if ( ! avconv -i "$f" ${FLAGS[$format]} -filter:v yadif "$t" \
|| ! test -s "${t}") && test -e "$t"; then
2015-03-31 13:59:17 +00:00
rm "$t"; # remove file if conversion failed
fi
done
done