Skip to content

Commit 262ea50

Browse files
committed
created script for video making
1 parent 1013407 commit 262ea50

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

tutorial1/avatar/make-video.sh

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
#!/bin/bash
22
set -e # Stop on error
33

4-
# Function to process a sequence (dark or light)
4+
# Function to process a sequence (dark or dark-dm)
55
process_sequence() {
66
prefix="$1"
7-
87
echo "Processing: $prefix"
98

10-
# Convert PPM to PNG
9+
# Detect background color based on suffix
10+
if [[ "$prefix" == *-dm ]]; then
11+
bg_color="black"
12+
else
13+
bg_color="white"
14+
fi
15+
16+
# Convert PPM to PNG (raw)
1117
for f in ${prefix}.*.ppm; do
12-
convert "$f" "${f%.ppm}.png"
18+
convert "$f" "${f%.ppm}.png"
1319
done
1420

15-
# Detect background color
16-
bg_color="black"
17-
if [[ "$prefix" == "light" ]]; then
18-
bg_color="white"
19-
fi
20-
2121
# Remove background & add alpha
2222
for f in ${prefix}.*.png; do
23-
convert "$f" -transparent "$bg_color" -fuzz 10% "${f%.png}_transparent.png"
23+
convert "$f" -transparent "$bg_color" -fuzz 10% "${f%.png}_transparent.png"
2424
done
2525

26-
# Resize
26+
# Resize to 50%
2727
for f in ${prefix}.*_transparent.png; do
28-
convert "$f" -resize 50% "$f"
28+
convert "$f" -resize 30% "$f"
2929
done
3030

3131
# Create movie
3232
[ -f "${prefix}.webp" ] && rm "${prefix}.webp"
33-
3433
ffmpeg -framerate 20 -i "${prefix}.%05d_transparent.png" \
35-
-loop 0 -lossless 0 -qscale 5 -g 1 "${prefix}.webp"
34+
-loop 0 -lossless 0 -qscale 5 -g 1 "${prefix}.webp"
3635

37-
# Cleanup PNGs
36+
# Cleanup
3837
rm ${prefix}.*.png
3938
convert ${prefix}.00000.ppm ${prefix}.png
4039
}
4140

42-
# Run for both dark and light sequences
43-
process_sequence "dark"
44-
process_sequence "light"
45-
41+
# Run for both light and dark
42+
process_sequence "avatar"
43+
process_sequence "avatar-dm"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e # Stop on error
3+
4+
# Define the base repo path once
5+
REPO_PATH="/home/simon/Git/GROMACS/main/docs/sphinx/source/tutorials/tutorial1/figures"
6+
7+
# Copy the images to their destinations
8+
cp avatar.webp "$REPO_PATH/bulk-solution.webp"
9+
cp avatar-dm.webp "$REPO_PATH/bulk-solution-dm.webp"
10+
11+
echo "✅ Images copied to $REPO_PATH"

0 commit comments

Comments
 (0)