Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foundfolders=0
- for folders in "$@" ;do
- if [ -d "$folders" ]; then
- echo "$folders"
- foundfolders=1
- fi
- done
- if [ $foundfolders = 0 ]; then
- echo "You need to drop some folders"
- exit
- fi
- echo #
- for folders in "$@" ;do
- echo encoding $folders
- if [ -d "$folders" ]; then
- echo "$folders"
- cd "$folders"
- # check if there are any jpg, png or tga files in folder
- jpgfound=0
- pngfound=0
- tgafound=0
- shopt -s nullglob
- for files in *.jpg ;do
- jpgfound=1
- done
- shopt -s nullglob
- for files in *.png ;do
- pngfound=1
- done
- shopt -s nullglob
- for files in *.tga ;do
- tgafound=1
- done
- if [ $jpgfound = 1 ]; then
- echo "some jpgs there"
- ext="jpg"
- fi
- if [ $tgafound = 1 ]; then
- ext="tga"
- echo "some tgas there"
- fi
- if [ $pngfound = 1 ]; then
- ext="png"
- echo "some pngs there"
- fi
- echo extension used will be $ext
- #set -o verbose #echo on
- #making temporary simbolic links to make ffmpeg happy with filenaming
- if [ -d "$folders" ]; then
- echo "$folders"
- x=1;
- for i in "$folders"/*"$ext"; do
- counter=$(printf %05d $x); ln -s "$i" /tmp/img"$counter"."$ext"; x=$(($x+1));
- done
- #encoding
- filename=$(basename "$folders")
- echo "$filename"
- # ffmpeg command:
- optionsCRF="-vcodec libx264 -preset medium -tune film -crf 21 -threads 0"
- set -x
- $ffmpeg -f image2 -i /tmp/img%05d."$ext" $optionsCRF "$folders"/"$filename".mp4
- set +x
- #removing temporary simbolic links
- x=1;
- for i in "$folders"/*"$ext"; do
- counter=$(printf %05d $x); rm /tmp/img"$counter"."$ext"; x=$(($x+1));
- done
- fi
- fi
- done
Add Comment
Please, Sign In to add comment