Reverses a video

This commit is contained in:
Abhay Rana 2015-02-10 19:33:38 +05:30
parent baffd09d63
commit 3c221c1b0e
1 changed files with 60 additions and 0 deletions

60
reverse_video.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
#######################
#Check for requirments#
#######################
zenity=$(which zenity)
if [ "$zenity" == "" ]; then
echo "You must have zenity installed"
exit 1
fi
#avconv=$(which avconv)
#if [ "$avconv" == ""]; then
# zenity --error --text="You must have avconv installed"
# exit 1
#fi
avconv=$(which avconv)
if [ "$avconv" == "" ]; then
echo "You must have avconv installed"
exit 1
fi
##################################
#Spawn frames into images/ folder#
##################################
mkdir images
cd images
#avconv -i ../$1 %d.jpg
avconv -i ../$1 %d.jpg
##############
#Count images#
##############
images=0
for i in $(ls | grep .jpg); do
let images=images+1
done
#####################################
#Rename images in the opposite order#
#####################################
i=1
factor=0
while [ $factor -lt $images ]; do
new_name=$((images-factor))
echo $new_name
mv $i.jpg image$new_name.jpg
let factor=factor+1
let i=i+1
done
###############################################
#Finally convert newly named images into video#
###############################################
#avconv -f image2 -i image%d.jpg -vcodec mpeg4 ../$2
avconv -f image2 -i image%d.jpg -vcodec mpeg4 ../$2
#######################
#Remove temporal files#
#######################
rm *.jpg