diff --git a/src/convert-videos.sh b/src/convert-videos.sh index 24623ff..e7d1915 100755 --- a/src/convert-videos.sh +++ b/src/convert-videos.sh @@ -11,19 +11,18 @@ 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 for format in ${FORMATS}; do - t="${f/$SRC/$DST/${format}}" t="${t%.*}.${f}" if test -s "${t}"; then - continue; + continue; # ignore if file exists and is not empty fi - if ( ! test -s "${t}" ) && ( test -e "$t" ); then - rm "$t" + if test -e "$t"; then + rm "$t"; # remove existing empty file fi test -d "${t%/*}" || mkdir -p "${t%/*}" - avconv -i "$f" ${FLAGS[$f]} -filter:v yadif "$t" - if ( ! test -s "${t}" ) && ( test -e "$t" ); then - rm "$t" + if ( ! avconv -i "$f" ${FLAGS[$f]} -filter:v yadif "$t" + || ! test -s "${t}") && test -e "$t"; then + rm "$t"; # remove file if conversion failed fi done done