From f519a869b3fcc199d569bfbd113633ab7a4a3709 Mon Sep 17 00:00:00 2001 From: zlei9 Date: Sun, 29 Mar 2026 14:29:02 +0800 Subject: [PATCH] Initial commit with translated description --- SKILL.md | 29 +++++++++++++++++ _meta.json | 6 ++++ scripts/frame.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 SKILL.md create mode 100644 _meta.json create mode 100644 scripts/frame.sh diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..0405d16 --- /dev/null +++ b/SKILL.md @@ -0,0 +1,29 @@ +--- +name: video-frames +description: "使用ffmpeg从视频中提取帧或短剪辑。" +homepage: https://ffmpeg.org +metadata: {"clawdbot":{"emoji":"🎞️","requires":{"bins":["ffmpeg"]},"install":[{"id":"brew","kind":"brew","formula":"ffmpeg","bins":["ffmpeg"],"label":"Install ffmpeg (brew)"}]}} +--- + +# Video Frames (ffmpeg) + +Extract a single frame from a video, or create quick thumbnails for inspection. + +## Quick start + +First frame: + +```bash +{baseDir}/scripts/frame.sh /path/to/video.mp4 --out /tmp/frame.jpg +``` + +At a timestamp: + +```bash +{baseDir}/scripts/frame.sh /path/to/video.mp4 --time 00:00:10 --out /tmp/frame-10s.jpg +``` + +## Notes + +- Prefer `--time` for “what is happening around here?”. +- Use a `.jpg` for quick share; use `.png` for crisp UI frames. diff --git a/_meta.json b/_meta.json new file mode 100644 index 0000000..f973e79 --- /dev/null +++ b/_meta.json @@ -0,0 +1,6 @@ +{ + "ownerId": "kn70pywhg0fyz996kpa8xj89s57yhv26", + "slug": "video-frames", + "version": "1.0.0", + "publishedAt": 1767545391700 +} \ No newline at end of file diff --git a/scripts/frame.sh b/scripts/frame.sh new file mode 100644 index 0000000..31b3adb --- /dev/null +++ b/scripts/frame.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat >&2 <<'EOF' +Usage: + frame.sh [--time HH:MM:SS] [--index N] --out /path/to/frame.jpg + +Examples: + frame.sh video.mp4 --out /tmp/frame.jpg + frame.sh video.mp4 --time 00:00:10 --out /tmp/frame-10s.jpg + frame.sh video.mp4 --index 0 --out /tmp/frame0.png +EOF + exit 2 +} + +if [[ "${1:-}" == "" || "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage +fi + +in="${1:-}" +shift || true + +time="" +index="" +out="" + +while [[ $# -gt 0 ]]; do + case "$1" in + --time) + time="${2:-}" + shift 2 + ;; + --index) + index="${2:-}" + shift 2 + ;; + --out) + out="${2:-}" + shift 2 + ;; + *) + echo "Unknown arg: $1" >&2 + usage + ;; + esac +done + +if [[ ! -f "$in" ]]; then + echo "File not found: $in" >&2 + exit 1 +fi + +if [[ "$out" == "" ]]; then + echo "Missing --out" >&2 + usage +fi + +mkdir -p "$(dirname "$out")" + +if [[ "$index" != "" ]]; then + ffmpeg -hide_banner -loglevel error -y \ + -i "$in" \ + -vf "select=eq(n\\,${index})" \ + -vframes 1 \ + "$out" +elif [[ "$time" != "" ]]; then + ffmpeg -hide_banner -loglevel error -y \ + -ss "$time" \ + -i "$in" \ + -frames:v 1 \ + "$out" +else + ffmpeg -hide_banner -loglevel error -y \ + -i "$in" \ + -vf "select=eq(n\\,0)" \ + -vframes 1 \ + "$out" +fi + +echo "$out"