360 Secure SkillHub
360 安全技能中心

Video to GIF

该 Skill 通过 Python 脚本调用 ffmpeg/ffprobe,把视频文件或指定片段转换为 GIF 或 WebP 动图,可设置起止时间与时长、fps、宽高缩放、循环次数与调色板颜色数,并给出体积压缩的取舍建议。

xiwei26
xiwei26
热度 21.13
最近更新 2026-05-12 11:11:51
分类:效率依赖:代码执行 / 读写文件应用场景:文件转换 / 视频编辑

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add video-to-gif-hq
Metadata
name
video-to-gif
description
Convert video files or clips into animated GIFs/WebP using ffmpeg, with resizing, fps control, trimming, palette generation, and file-size optimization. Use when the user asks to turn video into GIF/动图, make a GIF from mp4/mov/webm/mkv, extract a video segment as an animation, compress an animated GIF, or create a shareable short looping animation.

Video To GIF

Quick workflow

  1. Identify the input video path or ask the user to upload/provide it if missing.
  2. Choose sensible defaults unless the user specifies otherwise:
    • fps=12
    • keep the original video resolution by default; only resize when the user asks for compression/smaller file size or a target dimension
    • trim duration to ≤10 seconds if the user asks for a generic “动图” but the video is long
    • use palette generation for GIF quality
  3. Run scripts/video_to_gif.py from this skill directory.
  4. Verify the output exists and report path/size. Attach with MEDIA:<path> if delivering in chat.

Script usage

python3 /root/.openclaw/workspace/skills/video-to-gif/scripts/video_to_gif.py \
  input.mp4 output.gif \
  --start 00:00:02 --duration 4 \
  --fps 12 --width 480

Useful options:

  • --start: clip start time, e.g. 3.5 or 00:00:03.500
  • --duration: clip length in seconds or timestamp format
  • --end: alternative to duration
  • --fps: lower values reduce size; 10–15 is usually good
  • --width: scale output width while preserving aspect ratio
  • --height: scale output height while preserving aspect ratio
  • --output-format gif|webp: WebP is usually much smaller than GIF
  • --loop: 0 means loop forever
  • --max-colors: GIF palette colors, default 256; lower reduces size

Quality and size guidance

  • Default to original resolution for clarity.
  • For Feishu/chat stickers or size-sensitive sharing, ask/choose a smaller width such as --width 360 --fps 10.
  • If GIF is too large, reduce in this order: duration, width, fps, colors.
  • If the user only needs an animated image and not strict GIF, recommend WebP because it is smaller and smoother.

Dependencies

The script requires ffmpeg and ffprobe on PATH. If missing, tell the user the dependency is absent and do not attempt risky system installation without confirmation.