nexu-io/open-design / skills/oil-motion
oil-motion
Verified处理视频和序列帧,编译滚动、指针、拖动与状态驱动的网页动效;内含本地媒体处理脚本和运行时。新素材生成使用宿主工具。
scripts/media_edges.py
View on GitHub#!/usr/bin/env python3
"""确定性提取视频首帧与实际尾帧。"""
from __future__ import annotations
import subprocess
from pathlib import Path
def extract_edge_frame(video: str | Path, output: str | Path, edge: str) -> None:
source = Path(video).expanduser().resolve()
target = Path(output).expanduser().resolve()
if not source.is_file():
raise FileNotFoundError(f"视频不存在:{source}")
if edge not in {"head", "tail"}:
raise ValueError("edge 必须是 head 或 tail")
target.parent.mkdir(parents=True, exist_ok=True)
command = ["ffmpeg", "-hide_banner", "-loglevel", "error", "-y"]
if edge == "tail":
command.extend(["-sseof", "-3", "-i", str(source), "-update", "1"])
else:
command.extend(["-i", str(source), "-frames:v", "1"])
command.append(str(target))
completed = subprocess.run(command, capture_output=True, text=True)
if completed.returncode != 0 or not target.is_file() or target.stat().st_size == 0:
raise RuntimeError(
f"无法提取视频{edge}帧:{completed.stderr.strip() or source}"
)
def extract_first_frame(video: str | Path, output: str | Path) -> None:
extract_edge_frame(video, output, "head")
def extract_last_frame(video: str | Path, output: str | Path) -> None:
extract_edge_frame(video, output, "tail")
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |