Created
May 12, 2019 05:49
-
-
Save JupyterJones/62d42d02e0a46e141f4890e1379d6cef to your computer and use it in GitHub Desktop.
Rotate / spin an image and turn into am mp4 video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Create variable NUM starting at 0 | |
| NUM=0 | |
| # Create the directory images-spin if it does not exist | |
| [ -d images-spin ] || mkdir images-spin | |
| # Renove any *.png images that may exist in the directory | |
| rm images-spin/*.png | |
| # Create a loop of 360 ( $i for each degree of a circle ) | |
| for i in {1..360}; do | |
| # if $i divided by input variable $1 equals 0 ( no remainer ) | |
| if (( $i%$1==0 )); then | |
| # NUM = NUM + 1 | |
| NUM=$((NUM+1)) | |
| # Below is for debug | |
| #sleep 1 | |
| #echo Degrees $i, images-spin/$NUM-.png | |
| # Create and image rotated by $i degrees save as NUM-.png | |
| ffmpeg -hide_banner -i spin.png -vf "rotate="$i"*PI/180" images-spin/$NUM-.png | |
| # Resize the NUM-.png created to 720:720 save as NUM.png | |
| ffmpeg -hide_banner -i images-spin/$NUM-.png -vf scale=720:720 images-spin/$NUM.png | |
| fi ; | |
| done | |
| #Convert the $NUM.png images to a video | |
| ffmpeg -hide_banner -framerate 30 -i images-spin/%0d.png -vf scale=720x720 \ | |
| -c:v libx264 -r 30 -pix_fmt yuv420p -y "IMAGES-spin"$1".mp4" | |
| #remove any existing mylist.txt | |
| rm mylist.txt | |
| # Create a mylist.txt to concat into a longer video | |
| LIST="IMAGES-spin"$1".mp4" | |
| echo $LIST | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| echo "file '$LIST'" >>mylist.txt | |
| # Concat (join) all the file in mylist.txt into a file called long.mp4 | |
| ffmpeg -f concat -i mylist.txt -c copy long.mp4 | |
| # play long.mp4 with vlc player | |
| vlc long.mp4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment