Skill: ascendswang/ffmpeg-cli (version 1.0.0)

--- name: ffmpeg-cli description: Comprehensive video/audio processing with FFmpeg. Use for: (1) Video transcoding and format conversion, (2) Cutting and merging clips, (3) Audio extraction and manipulation, (4) Thumbnail and GIF generation, (5) Resolution scaling and quality adjustment, (6) Adding subtitles or watermarks, (7) Speed adjustment (slow/fast motion), (8) Color correction and filters. metadata: {"clawdbot":{"emoji":"🎬","requires":{"bins":["ffmpeg"]},"install":[{"id":"brew","kind":"brew","formula":"ffmpeg","bins":["ffmpeg"],"label":"Install ffmpeg (brew)"}]}} --- # FFmpeg CLI ## Quick Reference | Task | Command | |------|---------| | Cut video | `{baseDir}/scripts/cut.sh -i <input> -s <start> -e <end> -o <output>` | | Merge clips | `{baseDir}/scripts/merge.sh -o <output> <file1> <file2> ...` | | Extract audio | `{baseDir}/scripts/extract-audio.sh -i <video> -o <output.mp3>` | | Generate thumbnail | `{baseDir}/scripts/thumb.sh -i <video> -t <timestamp> -o <out.jpg>` | | Create GIF | `{baseDir}/scripts/gif.sh -i <video> -s <start> -e <end> -o <out.gif>` | | Convert format | `{baseDir}/scripts/convert.sh -i <input> -o <output.mp4>` | | Change speed | `{baseDir}/scripts/speed.sh -i <input> -r <0.5-2.0> -o <output>` | | Add watermark | `{baseDir}/scripts/watermark.sh -i <video> -w <image> -o <output>` | ## Scripts ### cut.sh - Cut video segment ```bash {baseDir}/scripts/cut.sh -i video.mp4 -s 00:01:30 -e 00:02:45 -o clip.mp4 ``` ### merge.sh - Concatenate videos ```bash {baseDir}/scripts/merge.sh -o merged.mp4 part1.mp4 part2.mp4 part3.mp4 ``` ### extract-audio.sh - Pull audio track ```bash {baseDir}/scripts/extract-audio.sh -i video.mp4 -o audio.mp3 ``` ### thumb.sh - Extract frame as image ```bash {baseDir}/scripts/thumb.sh -i video.mp4 -t 00:00:15 -o frame.jpg ``` ### gif.sh - Convert clip to GIF ```bash {baseDir}/scripts/gif.sh -i video.mp4 -s 00:00:10 -e 00:00:15 -o clip.gif ``` ### convert.sh - Transcode to new format ```bash {baseDir}/scripts/convert.sh -i input.avi -o output.mp4 ``` ### speed.sh - Adjust playback speed ```bash {baseDir}/scripts/speed.sh -i video.mp4 -r 2.0 -o fast.mp4 # 2x speed {baseDir}/scripts/speed.sh -i video.mp4 -r 0.5 -o slow.mp4 # 0.5x speed ``` ### watermark.sh - Overlay image watermark ```bash {baseDir}/scripts/watermark.sh -i video.mp4 -w logo.png -o output.mp4 ``` ## Notes - All scripts support common video formats (mp4, avi, mov, mkv, webm, etc.) - Output quality is optimized for balanced file size and clarity - Use `-h` or no args to see script usage

path: scripts/convert.sh
content: #!/bin/bash
# Convert video to different format
set -e

usage() {
    echo "Usage: $0 -i <input> -o <output>"
    echo "  -i <input>    Input file"
    echo "  -o <output>   Output file (extension determines format)"
    exit 1
}

while getopts "i:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$OUTPUT" ] && usage

ffmpeg -i "$INPUT" -c:v libx264 -crf 23 -c:a aac -b:a 128k -y "$OUTPUT"
echo "✅ Converted: $OUTPUT"


path: scripts/cut.sh
content: #!/bin/bash
# Cut video segment without re-encoding (fast)
set -e

usage() {
    echo "Usage: $0 -i <input> -s <start> -e <end> -o <output>"
    echo "  -i <input>    Input video file"
    echo "  -s <start>    Start time (HH:MM:SS or seconds)"
    echo "  -e <end>      End time (HH:MM:SS or seconds)"
    echo "  -o <output>   Output file"
    exit 1
}

while getopts "i:s:e:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        s) START="$OPTARG" ;;
        e) END="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$START" ] || [ -z "$END" ] || [ -z "$OUTPUT" ] && usage

ffmpeg -i "$INPUT" -ss "$START" -to "$END" -c copy -y "$OUTPUT"
echo "✅ Cut complete: $OUTPUT"


path: scripts/extract-audio.sh
content: #!/bin/bash
# Extract audio from video
set -e

usage() {
    echo "Usage: $0 -i <video> -o <output.mp3>"
    echo "  -i <video>    Input video file"
    echo "  -o <output>   Output audio file (mp3/aac)"
    exit 1
}

while getopts "i:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$OUTPUT" ] && usage

ffmpeg -i "$INPUT" -vn -acodec libmp3lame -q:a 2 -y "$OUTPUT"
echo "✅ Audio extracted: $OUTPUT"


path: scripts/gif.sh
content: #!/bin/bash
# Convert video to GIF
set -e

usage() {
    echo "Usage: $0 -i <video> -s <start> -e <end> -o <output.gif>"
    echo "  -i <video>    Input video file"
    echo "  -s <start>    Start time (HH:MM:SS or seconds)"
    echo "  -e <end>      End time (HH:MM:SS or seconds)"
    echo "  -o <output>   Output GIF file"
    exit 1
}

while getopts "i:s:e:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        s) START="$OPTARG" ;;
        e) END="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$START" ] || [ -z "$END" ] || [ -z "$OUTPUT" ] && usage

# Scale to reasonable size for GIF
ffmpeg -ss "$START" -to "$END" -i "$INPUT" -vf "fps=10,scale=480:-1:flags=lanczos" -c:v gif -y "$OUTPUT"
echo "✅ GIF created: $OUTPUT"


path: scripts/merge.sh
content: #!/bin/bash
# Merge multiple video files
set -e

usage() {
    echo "Usage: $0 -o <output> <file1> <file2> ..."
    echo "  -o <output>   Output file"
    echo "  <files...>    Input video files"
    exit 1
}

OUTPUT=""

while getopts "o:h" opt; do
    case $opt in
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

shift $((OPTIND-1))

[ -z "$OUTPUT" ] && usage
[ $# -eq 0 ] && usage

# Create file list for ffmpeg concat
TEMP_LIST=$(mktemp /tmp/ffmpeg_merge_XXXXXX.txt)
for f in "$@"; do
    echo "file '$f'" >> "$TEMP_LIST"
done

ffmpeg -f concat -safe 0 -i "$TEMP_LIST" -c copy -y "$OUTPUT"
rm -f "$TEMP_LIST"

echo "✅ Merge complete: $OUTPUT"


path: scripts/speed.sh
content: #!/bin/bash
# Change video playback speed
set -e

usage() {
    echo "Usage: $0 -i <input> -r <rate> -o <output>"
    echo "  -i <input>    Input video file"
    echo "  -r <rate>     Speed rate (0.5 = half speed, 2.0 = double speed)"
    echo "  -o <output>   Output file"
    exit 1
}

RATE=1.0

while getopts "i:r:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        r) RATE="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$RATE" ] || [ -z "$OUTPUT" ] && usage

# Use atempo for 0.5-2.0 range, chain for beyond
if (( $(echo "$RATE > 2.0" | bc -l) )); then
    FILTERS="atempo=2.0,atempo=$(echo "$RATE/2" | bc -l)"
elif (( $(echo "$RATE < 0.5" | bc -l) )); then
    FILTERS="atempo=0.5,atempo=$(echo "$RATE*2" | bc -l)"
else
    FILTERS="atempo=$RATE"
fi

ffmpeg -i "$INPUT" -filter:a "$FILTERS" -filter:v "setpts=${RATE}*PTS" -c:v libx264 -crf 23 -c:a aac -y "$OUTPUT"
echo "✅ Speed adjusted ($RATEx): $OUTPUT"


path: scripts/thumb.sh
content: #!/bin/bash
# Generate thumbnail from video
set -e

usage() {
    echo "Usage: $0 -i <video> [-t <timestamp>] -o <output.jpg>"
    echo "  -i <video>     Input video file"
    echo "  -t <timestamp> Timestamp for frame (default: 00:00:01)"
    echo "  -o <output>    Output image file"
    exit 1
}

TIMESTAMP="00:00:01"

while getopts "i:t:o:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        t) TIMESTAMP="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$OUTPUT" ] && usage

ffmpeg -ss "$TIMESTAMP" -i "$INPUT" -vframes 1 -q:v 2 -y "$OUTPUT"
echo "✅ Thumbnail saved: $OUTPUT"


path: scripts/watermark.sh
content: #!/bin/bash
# Add watermark to video
set -e

usage() {
    echo "Usage: $0 -i <video> -w <watermark> -o <output>"
    echo "  -i <video>      Input video file"
    echo "  -w <watermark>  Watermark image file"
    echo "  -o <output>     Output file"
    exit 1
}

POS="10:10"  # Default: top-left

while getopts "i:w:o:p:h" opt; do
    case $opt in
        i) INPUT="$OPTARG" ;;
        w) WATERMARK="$OPTARG" ;;
        o) OUTPUT="$OPTARG" ;;
        p) POS="$OPTARG" ;;
        h) usage ;;
        *) usage ;;
    esac
done

[ -z "$INPUT" ] || [ -z "$WATERMARK" ] || [ -z "$OUTPUT" ] && usage

ffmpeg -i "$INPUT" -i "$WATERMARK" -filter_complex "[0:v][1:v] overlay=$POS" -c:a copy -y "$OUTPUT"
echo "✅ Watermark added: $OUTPUT"


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (MEDIUM)