Free sampleMIT licence
ffmpeg helpers: stage AI clips, all-keyframe encode, 9:16 mobile reframe
ffmpeg helpers: stage AI clips, all-keyframe encode, 9:16 mobile reframe
toolTool from yojahny55/cinematic-scroll-kit.
From prompt to live site
- 01
Copy the code
Grab every file as one text, each carrying its licence notice.
- 02
Paste into your AI
Drop it into Claude, Cursor or v0 — or straight into your own project.
- 03
Launch it live
Adapt the copy, wire your data, and ship — with the notice kept alongside.
Read the full code
ffmpeg helpers: stage AI clips, all-keyframe encode, 9:16 mobile reframe
yojahny55/cinematic-scroll-kit@270f69d7f90d · 3 code file(s)
Licence notice — required by the licence; keep it with this code:
MIT License
Copyright (c) 2026 Cinematic Scroll Kit contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Runtime dependencies (loaded via CDN, not bundled):
- Lenis (https://github.com/studio-freight/lenis) — MIT License
- GSAP + ScrollTrigger (https://greensock.com/gsap/) — free for personal and
non-commercial use under the GreenSock standard "no charge" license. Commercial
use requires a Club GreenSock license (https://greensock.com/club).
If you ship a commercial product using this kit, ensure you have the
appropriate GreenSock license or replace ScrollTrigger with a self-rolled
IntersectionObserver implementation.
--- encode-keyframe.sh ---
#!/usr/bin/env bash
# Encode all MP4s in SRC to DEST with all-keyframe H.264.
# Result: video.currentTime = X seeks frame-perfectly. Required for scroll-scrub.
#
# Usage: ./encode-keyframe.sh <src-dir> <dest-dir>
# Example: ./encode-keyframe.sh videos/_orig videos
set -euo pipefail
SRC="${1:-}"
DEST="${2:-}"
if [[ -z "$SRC" || -z "$DEST" ]]; then
echo "Usage: $0 <src-dir> <dest-dir>"
exit 1
fi
mkdir -p "$DEST"
shopt -s nullglob
for f in "$SRC"/*.mp4; do
name="$(basename "$f")"
echo "→ $name"
ffmpeg -y -i "$f" \
-an \
-c:v libx264 -preset slow -crf 20 \
-g 1 -keyint_min 1 -sc_threshold 0 \
-x264-params "rc-lookahead=0:ref=1:bframes=0" \
-pix_fmt yuv420p \
-movflags +faststart \
"$DEST/$name" \
-loglevel error -stats
size=$(stat -c%s "$DEST/$name" 2>/dev/null || stat -f%z "$DEST/$name")
printf " ✓ %s (%.1fM)\n" "$name" "$(echo "$size/1048576" | bc -l)"
done
echo "Done. $(ls "$DEST"/*.mp4 | wc -l) files in $DEST."
--- encode-mobile-portrait.sh ---
#!/usr/bin/env bash
# Re-encode 16:9 MP4s to 9:16 portrait (720x1280, center-cropped) for mobile autoplay-loop.
#
# Usage: ./encode-mobile-portrait.sh <src-dir> <dest-dir>
# Example: ./encode-mobile-portrait.sh videos/_orig videos/mobile
set -euo pipefail
SRC="${1:-}"
DEST="${2:-}"
if [[ -z "$SRC" || -z "$DEST" ]]; then
echo "Usage: $0 <src-dir> <dest-dir>"
exit 1
fi
mkdir -p "$DEST"
shopt -s nullglob
for f in "$SRC"/*.mp4; do
name="$(basename "$f")"
echo "→ $name (→ 720x1280 portrait)"
ffmpeg -y -i "$f" \
-an \
-vf "scale=-2:1280:flags=lanczos,crop=720:1280:(iw-720)/2:0" \
-c:v libx264 -preset slow -crf 24 \
-g 24 -keyint_min 24 \
-pix_fmt yuv420p \
-movflags +faststart \
"$DEST/$name" \
-loglevel error -stats
size=$(stat -c%s "$DEST/$name" 2>/dev/null || stat -f%z "$DEST/$name")
printf " ✓ %s (%.1fM)\n" "$name" "$(echo "$size/1048576" | bc -l)"
done
echo "Done. $(ls "$DEST"/*.mp4 | wc -l) files in $DEST."
--- stage-sources.sh ---
#!/usr/bin/env bash
# Take AI-generated clips with arbitrary names (from Kling, Runway, Sora etc.)
# and rename them into sequential 01.mp4 ... 0N.mp4 in DEST.
#
# Usage: ./stage-sources.sh <src-dir> <dest-dir>
# - <src-dir>: folder containing your generated clips (sorted by filename = scene order)
# - <dest-dir>: where the renamed sequential files go
set -euo pipefail
SRC="${1:-}"
DEST="${2:-}"
if [[ -z "$SRC" || -z "$DEST" ]]; then
echo "Usage: $0 <src-dir> <dest-dir>"
echo "Tip: source files should be alphabetically sortable in scene order."
exit 1
fi
mkdir -p "$DEST"
i=1
shopt -s nullglob
for f in $(ls "$SRC"/*.mp4 | sort); do
num=$(printf "%02d" "$i")
cp -n "$f" "$DEST/$num.mp4"
echo " $f → $DEST/$num.mp4"
i=$((i+1))
done
echo "Staged $((i-1)) clips to $DEST."
Source and licence
Source: yojahny55/cinematic-scroll-kit@270f69d7f90d
Author: 2026 Cinematic Scroll Kit contributors
Entry: scripts/encode-keyframe.sh
- needs ffmpeg; bash scripts
MIT License Copyright (c) 2026 Cinematic Scroll Kit contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- Runtime dependencies (loaded via CDN, not bundled): - Lenis (https://github.com/studio-freight/lenis) — MIT License - GSAP + ScrollTrigger (https://greensock.com/gsap/) — free for personal and non-commercial use under the GreenSock standard "no charge" license. Commercial use requires a Club GreenSock license (https://greensock.com/club). If you ship a commercial product using this kit, ensure you have the appropriate GreenSock license or replace ScrollTrigger with a self-rolled IntersectionObserver implementation.
Files (3)
- encode-keyframe.sh (1,017 bytes)
- encode-mobile-portrait.sh (1,014 bytes)
- stage-sources.sh (828 bytes)
Want the whole library?
Every item's prompt, code and instructions, with a CreativePower subscription.