Skip to content

Commit

Permalink
switch vhs strategy and add audio
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman committed Dec 26, 2024
1 parent 1856da7 commit 33956c4
Show file tree
Hide file tree
Showing 22 changed files with 273 additions and 28 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ jobs:
VERSION=$(curl -s https://api.github.com/repos/cloudposse/atmos/releases/latest | jq -r .tag_name)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: List all .tape files
id: list-tapes
run: |
files=$(git ls-files | grep 'demo.tape$' || true)
if [ -z "$files" ]; then
echo "matrix=[]" >> $GITHUB_OUTPUT
else
matrix=$(echo "$files" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
fi
cat $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.list-tapes.outputs.matrix }}
version: ${{ steps.get-version.outputs.version }}

screengrabs:
Expand Down Expand Up @@ -94,12 +81,6 @@ jobs:
needs: [prepare]
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
matrix:
file: ${{ fromJson(needs.prepare.outputs.matrix) }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.file }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -132,7 +113,6 @@ jobs:
id: vars
run: |
VERSION="${{ needs.prepare.outputs.version }}"
JOB_NAME=$(basename "${{ matrix.file }}" | sed 's/.tape$//')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "job_name=${JOB_NAME}" >> $GITHUB_OUTPUT
echo "branch_name=chore/update-${JOB_NAME}-for-${VERSION}" >> $GITHUB_OUTPUT
Expand All @@ -145,7 +125,8 @@ jobs:

- name: Record screencast
run: |
vhs ${{ matrix.file }}
demo/recordings/build.sh
mv demo/recordings/gif/atmos.gif docs/demo.gif
- name: Create or update PR
uses: peter-evans/create-pull-request@v7
Expand All @@ -168,6 +149,9 @@ jobs:
echo "## Demo GIF" >> $GITHUB_STEP_SUMMARY
echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/docs/demo.gif?raw=true)" >> $GITHUB_STEP_SUMMARY
echo "## Demo Video" >> $GITHUB_STEP_SUMMARY
echo "![Demo Video](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/demo/recordings/mp4/atmos-with-audio.mp4?raw=true)" >> $GITHUB_STEP_SUMMARY
- name: No changes
if: steps.auto-commit.outputs.pull-request-operation == 'none' || steps.auto-commit.outputs.pull-request-operation == 'closed'
run: |
Expand Down
7 changes: 5 additions & 2 deletions demo/defaults.tape
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# VHS Defaults for Recordings and Screenshots

Set Theme "Monokai Vivid"
#Set Theme "Monokai Vivid"

# It's not possible to combine named themes, with explicitly defined themes
Set Theme { "name": "Monokai Vivid", "black": "#121212", "red": "#fa2934", "green": "#98e123", "yellow": "#fff30a", "blue": "#0443ff", "magenta": "#f800f8", "cyan": "#01b6ed", "white": "#ffffff", "brightBlack": "#838383", "brightRed": "#f6669d", "brightGreen": "#b1e05f", "brightYellow": "#fff26d", "brightBlue": "#0443ff", "brightMagenta": "#f200f6", "brightCyan": "#51ceff", "brightWhite": "#ffffff", "background": "#121212", "foreground": "#f9f9f9", "cursor": "#b3b0d6", "selection": "#ffffff"}

Set FontFamily "FiraCode Nerd Font"
#Set FontFamily "Hack Nerd Font"
Set FontSize 14

Set TypingSpeed 40ms
Set TypingSpeed 20ms

Set WindowBar Colorful

Expand Down
Binary file added demo/recordings/LICENSE.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions demo/recordings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
> [!IMPORTANT]
> Certain MP3 and MP4 files in this directory, including any derivatives, are subject to the [Artlist license](LICENSE.pdf).
> This license is valid for the atmos project.
> Please ensure you comply with its terms when using or distributing these files.
Binary file added demo/recordings/background.mp3
Binary file not shown.
90 changes: 90 additions & 0 deletions demo/recordings/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
set -euo pipefail

# ---------------------------------------------------------------------
# build.sh
# Executes VHS from the root of the git repository
# Converts tapes/*.tape to mp4/*.mp4, processes scenes, and generates gifs
# ---------------------------------------------------------------------

# Resolve absolute paths for key directories
REPO_ROOT="$(git rev-parse --show-toplevel)"
TAPES_DIR="$REPO_ROOT/demo/recordings/tapes"
SCENES_DIR="$REPO_ROOT/demo/recordings/scenes"
MP4_OUTDIR="$REPO_ROOT/demo/recordings/mp4"
GIF_OUTDIR="$REPO_ROOT/demo/recordings/gif"
AUDIO_FILE="$REPO_ROOT/demo/recordings/background.mp3"

# Handle "clean" argument
if [[ "${1:-}" == "clean" ]]; then
echo ">> Cleaning up generated files..."
rm -rf "$MP4_OUTDIR" "$GIF_OUTDIR"
exit 0
fi

# Ensure output directories exist
echo ">> Ensuring $MP4_OUTDIR and $GIF_OUTDIR exist"
mkdir -p "$MP4_OUTDIR" "$GIF_OUTDIR"

# 1) Convert each tapes/*.tape => mp4/<basename>.mp4
echo ">> Step 1: Converting $TAPES_DIR/*.tape to $MP4_OUTDIR/*.mp4 via VHS"
shopt -s nullglob
TAPEFILES=( "$TAPES_DIR"/*.tape )
if [[ ${#TAPEFILES[@]} -eq 0 ]]; then
echo "No .tape files found in $TAPES_DIR. Exiting."
exit 1
fi

for tape in "${TAPEFILES[@]}"; do
base="$(basename "$tape" .tape)"
echo " Processing $tape -> $MP4_OUTDIR/$base.mp4"
(cd "$REPO_ROOT" && vhs "$tape" --output "$MP4_OUTDIR/$base.mp4")
done

# 2) Process scenes/*.txt
echo ">> Step 2: Building each scene from $SCENES_DIR/*.txt"
SCENE_FILES=( "$SCENES_DIR"/*.txt )
if [[ ${#SCENE_FILES[@]} -eq 0 ]]; then
echo "No scene text files found in $SCENES_DIR. Skipping scene-building steps."
exit 0
fi

for scene_file in "${SCENE_FILES[@]}"; do
scene_name="$(basename "$scene_file" .txt)"

echo " Scene: $scene_file => $scene_name"

# Concatenate scene
echo " Concatenating -> $MP4_OUTDIR/$scene_name.mp4"
ffmpeg -f concat -safe 0 -i "$scene_file" -c copy "$MP4_OUTDIR/$scene_name.mp4"

# Add audio fade
echo " Adding fade audio -> $MP4_OUTDIR/$scene_name-with-audio.mp4"
DURATION="$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$MP4_OUTDIR/$scene_name.mp4")"
FADE_START=$(( ${DURATION%.*} - 5 ))
ffmpeg -i "$MP4_OUTDIR/$scene_name.mp4" -i "$AUDIO_FILE" \
-filter_complex "[1:a]afade=t=out:st=${FADE_START}:d=5[aout]" \
-map 0:v -map "[aout]" \
-c:v copy -shortest -c:a aac "$MP4_OUTDIR/$scene_name-with-audio.mp4"

# Create GIF
echo " Creating GIF -> $GIF_OUTDIR/$scene_name.gif"
ffmpeg -y -i "$MP4_OUTDIR/$scene_name-with-audio.mp4" \
-vf palettegen "$GIF_OUTDIR/$scene_name-palette.png"

ffmpeg -i "$MP4_OUTDIR/$scene_name-with-audio.mp4" \
-i "$GIF_OUTDIR/$scene_name-palette.png" \
-lavfi "fps=10 [video]; [video][1:v] paletteuse" \
-y "$GIF_OUTDIR/$scene_name.gif"

echo " Done with scene: $scene_name"
done

echo
echo ">> Done building scenes!"
echo " Segments: $MP4_OUTDIR/<segment>.mp4"
echo " Scenes: $MP4_OUTDIR/<scene>.mp4"
echo " Audio: $MP4_OUTDIR/<scene>-with-audio.mp4"
echo " GIFs: $GIF_OUTDIR/<scene>.gif"
echo
echo "Use './build.sh clean' to remove them."
20 changes: 20 additions & 0 deletions demo/recordings/freeze.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"window": true,
"border": {
"radius": 8,
"width": 1,
"color": "#515151"
},
"shadow": {
"blur": 20,
"x": 0,
"y": 10
},
"padding": [20, 40, 20, 20],
"margin": "40",
"font": {
"family": "JetBrains Mono",
"size": 14
},
"line_height": 1.2
}
13 changes: 13 additions & 0 deletions demo/recordings/scenes/atmos.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
file '../mp4/atmos-version.mp4'
file '../mp4/ls-quick-start.mp4'
file '../mp4/atmos-vendor-pull.mp4'
file '../mp4/atmos-tui.mp4'
file '../mp4/atmos-list-components.mp4'
file '../mp4/atmos-docs.mp4'
file '../mp4/atmos-list-stacks.mp4'
file '../mp4/atmos-validate-stacks.mp4'
file '../mp4/atmos-describe-stacks.mp4'
file '../mp4/atmos-workflows.mp4'
file '../mp4/atmos-help.mp4'
file '../mp4/atmos-terraform-help.mp4'
file '../mp4/atmos-outro.mp4'
16 changes: 11 additions & 5 deletions demo/recordings/style.tape
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# VHS Defaults for Recordings

#Set Framerate 10
#Set CursorBlink true
#Set Margin 20
#Set MarginFill "#674EFF"
Set Framerate 10
Set CursorBlink true
Set Margin 20
Set MarginFill "#674EFF"

#Set Width 1400
#Set Height 800

#Set PlaybackSpeed 1
Set PlaybackSpeed 3

Hide
Type "alias ls='ls --color=force'" Enter Sleep 500ms
Type "cd examples/quick-start-advanced" Sleep 500ms Enter
Type "clear" Enter Sleep 500ms
Show
18 changes: 18 additions & 0 deletions demo/recordings/tapes/atmos-describe-stacks.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Let's review the production VPC configuration in the us-east-2 region..." Sleep 500ms Enter
Type "atmos describe stacks --components=vpc --stack=plat-ue2-prod --sections=vars" Sleep 500ms Enter
Sleep 2s

Type "# Or checkout all VPCs" Sleep 500ms Enter
Type "atmos describe stacks --components=vpc --sections=vars | less" Sleep 500ms Enter
Sleep 1s

Down 25 Sleep 500ms
Down 25 Sleep 500ms
Down 25 Sleep 500ms
Down 25 Sleep 500ms

Type "q" Sleep 500ms
Sleep 1s
7 changes: 7 additions & 0 deletions demo/recordings/tapes/atmos-docs.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Then we can learn about the VPC component" Sleep 500ms Enter
Type "atmos docs vpc" Sleep 500ms Enter
Sleep 2s
Type "q" Sleep 500ms Enter
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-help.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Atmos has a lot of documented commands" Sleep 500ms Enter
Type "atmos --help" Sleep 500ms Enter
Sleep 3s
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-list-components.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Let's see what components we have available!" Sleep 500ms Enter
Type "atmos list components" Sleep 500ms Enter
Sleep 1s
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-list-stacks.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Now, let's see where they are deployed" Sleep 500ms Enter
Type "atmos list stacks" Sleep 500ms Enter
Sleep 2s
8 changes: 8 additions & 0 deletions demo/recordings/tapes/atmos-outro.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Check out the docs at https://atmos.tools/" Sleep 500ms Enter
Sleep 2s

Type "# or join us in #atmos at https://cloudposse.com/slack!" Sleep 500ms Enter
Sleep 3s
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-terraform-help.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# Atmos has native workflows for Terraform" Sleep 500ms Enter
Type "atmos terraform --help" Sleep 500ms Enter
Sleep 5s
20 changes: 20 additions & 0 deletions demo/recordings/tapes/atmos-tui.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# In Atmos you can easily explore components, stacks, and run commands..." Sleep 500ms Enter
Type "atmos" Sleep 500ms Enter
Sleep 2s
Down Sleep 500ms
Down Sleep 500ms
Up Sleep 500ms
Up Sleep 500ms
Up Sleep 500ms
Up Sleep 500ms
Up Sleep 1s
Right Sleep 1s
Down Sleep 500ms
Right Sleep 1s
Down Sleep 500ms
Up Sleep 1s
Enter
Sleep 1s
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-validate-stacks.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# And validate the stack configurations" Sleep 500ms Enter
Type "atmos validate stacks" Sleep 500ms Enter
Sleep 2s
6 changes: 6 additions & 0 deletions demo/recordings/tapes/atmos-vendor-pull.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# We will start by installing some 3rd-party components and other artifacts..." Sleep 500ms Enter
Type "atmos vendor pull" Sleep 500ms Enter
Sleep 9s
7 changes: 7 additions & 0 deletions demo/recordings/tapes/atmos-version.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Sleep 500ms
Type "# First check you have Atmos installed" Sleep 500ms Enter
Type "atmos version" Sleep 500ms Enter
Sleep 2s
16 changes: 16 additions & 0 deletions demo/recordings/tapes/atmos-workflows.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Type "# In Atmos you can easily explore workflows and execute workflow commands..." Sleep 500ms Enter
Type "atmos workflow" Sleep 500ms Enter
Sleep 2s
Down Sleep 500ms
Right Sleep 500ms
Down Sleep 500ms
Right Sleep 500ms
Down Sleep 500ms
Down Sleep 500ms
Up Sleep 500ms
Up Sleep 500ms
Enter
Sleep 3s
13 changes: 13 additions & 0 deletions demo/recordings/tapes/ls-quick-start.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source demo/defaults.tape
Source demo/recordings/style.tape

Hide
Type "cd ../../" Sleep 500ms Enter
Type "clear" Enter Sleep 500ms
Show

Type "# Now let's explore the Quick Start example" Sleep 500ms Enter
Type "cd examples/quick-start-advanced" Sleep 500ms Enter

Type "ls -al" Sleep 500ms Enter
Sleep 1s

0 comments on commit 33956c4

Please sign in to comment.