Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Created by Kris Occhipinti
- #Copyright September 2018
- #http://filmsbykris.com
- #License - GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
- dir="$HOME/storage/dcim/Camera/"
- output="$(date +%s)"
- open="termux-open"
- #image scale size
- scale=320
- #frame rate
- rate=10
- #move to photo dir
- cd "$dir"
- #if r argument, then create reverse loop
- if [ "$1" = "r" ]
- then
- reverse=true
- fi
- #shopt -nullglob
- files=( *.mp4 )
- let x=0;
- for i in "${files[@]}"
- do
- echo "$x)$i"
- let x++
- done
- echo -n "Select a number: "
- read vid
- v="${files[vid]}"
- function progress(){
- while [ $convert ]
- do
- sleep 1
- clear
- echo "Creating Loop..."
- ls -la ${output}_loop.gif|awk '{print $5}'
- done
- }
- #does file exist?
- if [ -f "$v" ]
- then
- pal="$HOME/pal.png"
- rm $pal
- ffmpeg -i $v -vf \ fps=15,scale=320:-1:flags=lanczos,palettegen $pal
- #if reverse if true, make reverse loop
- if [ $reverse ]
- then
- ffmpeg -i "$v" -filter_complex \
- "[0:v]reverse,fifo[r];[0:v][0:a][r] [0:a]concat=n=2:v=1:a=1 [v] [a]"\
- -map "[v]" -map "[a]" -r $rate $output.mp4
- ffmpeg -i "$output.mp4" -i $pal -filter_complex "fps=$rate,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" $output.gif
- #ffmpeg -i "$output.mp4" -vf scale=$scale:-1 -r $rate $output.gif
- rm "$output.mp4"
- else
- ffmpeg -i "$v" -i $pal -filter_complex "fps=$rate,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" $output.gif
- #ffmpeg -i "$v" -vf scale=$scale:-1 -r $rate $output.gif
- fi
- else
- echo "Bad selection"
- exit 1
- fi
- $open $output.gif
- rm $pal
- clear
- ls -lh $output.gif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement