-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerateAnimationFromPNG.sh
executable file
·38 lines (31 loc) · 1.19 KB
/
generateAnimationFromPNG.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# ------------------------------------------------------------------- #
# Script to generate a video using ffmpeg from a series of pngs.
# Framerate can be given as an optional argument; default=10fps.
#
# Example call:
# generateAnimationFromPNG 8
# generateAnimationFromPNG
#
# Regis Thedin
# June 10, 2021
# ------------------------------------------------------------------- #
generateAnimationFromPNG(){
# Check paths
if [[ ${PWD##*/} == animation ]]; then
:
elif [ -d animation ]; then
cd animation
else
>&2 echo "generateAnimationFromPNG: The animation directory does not seem to exist on the top level directory of this case. Stopping."
return 1
fi
# get optional framerate from function call if defined
frate=${1:-10}
# get unique slices saved as pngs
uniqueSlices=$(for file in *.png; do echo "${file%.*.png}"; done | sort -u)
for slice in $uniqueSlices; do
yes | /home/rthedin/share/ffmpeg-git-20191022-amd64-static/ffmpeg -framerate $frate -i ${slice}.%4d.png -vcodec libx264 -crf 15 -pix_fmt yuv420p -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" video_${slice}.mp4
done
}