Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

assemble-media

БесплатноБез исполняемых скриптовНе проверен

Use to join, trim, mix, subtitle or inspect generated media, make frames and masks for the next generation, or make a simple video from pictures, text or a…

mudlerот mudler★ 50 644 звезды на GitHub

Об этом скилле

Assemble generated media

Generate the pieces with the LocalAI tools, then rework them with the shell tools of the media sandbox: ffmpeg, ffprobe, sox, magick and Python with Pillow. There is no network. Work in the folder where the pieces are.

Find the files

A generation tool returns a ref, a path such as /workspace/home/generated/clip-1a2b3c4d.mp4. Use that exact path; do not guess names. List what exists with ls -lt /workspace/home/generated | head. Write results next to the inputs, with new names (never overwrite a piece), then give the user the output path. A file in that folder can be passed to a tool as an argument (start_image, image, mask, audio).

Loop

  1. Generate one piece. Do not generate all pieces before checking the first.
  2. Inspect it: ffprobe for the facts, one frame grab for the picture (below). Look at the PNG.
  3. If it is wrong (size, length, no audio, bad frame), say so and fix the prompt or the command. Do not retry in a cycle.
  4. Assemble with the recipes below, then inspect the result the same way.

Inspect

cd /workspace/home/generated
ffprobe -v error -show_entries format=duration:stream=index,codec_type,codec_name,width,height,r_frame_rate,sample_rate,channels -of default=nw=1 a.mp4
ffmpeg -y -v error -ss 1 -i a.mp4 -frames:v 1 a-frame.png
ffmpeg -hide_banner -nostats -i voice.wav -af volumedetect -f null - 2>&1 | grep -E 'mean_volume|max_volume'

Look at a frame PNG with the file tools, or describe it with describe_image.

Join clips

Same codec, size and frame rate (clips of one model and settings), no re-encode:

printf "file '%s'\n" a.mp4 a.mp4 > list.txt
ffmpeg -y -v error -f concat -safe 0 -i list.txt -c copy joined.mp4

Different size, frame rate, codec, or some clips without audio: write this script once, then run sh /tmp/vconcat.sh out.mp4 1280 720 24 a.mp4 b.mp4. It scales each clip to fit with black bars, adds silence to clips with no audio, and joins them.

cat > /tmp/vconcat.sh <<'EOF2'
#!/bin/sh
# usage: vconcat.sh out.mp4 WIDTH HEIGHT FPS clip...
set -e
out=$1; w=$2; h=$3; fps=$4; shift 4
vf="scale=$w:$h:force_original_aspect_ratio=decrease,pad=$w:$h:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=$fps,format=yuv420p"
enc="-c:v libx264 -preset veryfast -crf 20 -c:a aac -ar 48000 -ac 2"
dir=$(mktemp -d); : > "$dir/list.txt"; i=0
for f in "$@"; do
  i=$((i+1)); n="$dir/$i.mp4"
  if [ -n "$(ffprobe -v error -select_streams a -show_entries stream=index -of csv=p=0 "$f")" ]; then
    ffmpeg -y -v error -i "$f" -vf "$vf" $enc "$n"
  else
    ffmpeg -y -v error -i "$f" -f lavfi -i anullsrc=r=48000:cl=stereo -map 0:v -map 1:a -shortest -vf "$vf" $enc "$n"
  fi
  echo "file '$n'" >> "$dir/list.txt"
done
ffmpeg -y -v error -f concat -safe 0 -i "$dir/list.txt" -c copy "$out"
rm -rf "$dir"
EOF2
sh /tmp/vconcat.sh joined2.mp4 1280 720 24 a.mp4 b.mp4

Audio track

# replace or add the audio of a video; the result ends with the shorter input
ffmpeg -y -v error -i a.mp4 -i music.wav -map 0:v -map 1:a -c:v copy -c:a aac -shortest withaudio.mp4
# audio shorter than the video: pad it with silence to the video length
ffmpeg -y -v error -i a.mp4 -i voice.wav -map 0:v -map 1:a -c:v copy -c:a aac -af apad -shortest withvoice.mp4

Voice over music: the music ducks under the voice. To start the voice later, write [1:a]adelay=1500|1500,apad,... (milliseconds). apad keeps the music playing after the voice ends.

ffmpeg -y -v error -i music.wav -i voice.wav -filter_complex \
 "[1:a]apad,asplit=2[v][sc];[0:a][sc]sidechaincompress=threshold=0.03:ratio=8:attack=20:release=400[d];[d][v]amix=inputs=2:duration=first:normalize=0[a]" \
 -map "[a]" mix-raw.wav

Normalise loudness to -16 LUFS in two passes. A single loudnorm pass levels quiet parts up and undoes the ducking. Save this script once, then run sh /tmp/lnorm.sh mix-raw.wav mix.wav:

cat > /tmp/lnorm.sh <<'EOF2'
#!/bin/sh
# usage: lnorm.sh in out   (audio or video with audio in; wav out)
set -e
t="I=-16:TP=-1.5:LRA=11"
m=$(ffmpeg -hide_banner -nostats -i "$1" -af "loudnorm=$t:print_format=json" -f null - 2>&1)
g() { echo "$m" | grep "\"$1\"" | sed 's/.*: "\(.*\)".*/\1/'; }
ffmpeg -y -v error -i "$1" -af "loudnorm=$t:measured_I=$(g input_i):measured_TP=$(g input_tp):measured_LRA=$(g input_lra):measured_thresh=$(g input_thresh):offset=$(g target_offset):linear=true" -ar 44100 "$2"
EOF2
sh /tmp/lnorm.sh mix-raw.wav mix.wav

Put the mix on a video with the first command of this section. sox is shorter for plain audio work:

sox voice.wav music.wav both.wav          # one after the other
sox voice.wav fast.wav tempo 1.25         # faster, same pitch
sox voice.wav quiet.wav norm -3           # peak at -3 dB

Convert: ffmpeg -y -v error -i voice.wav -c:a libmp3lame -q:a 2 voice.mp3, or -c:a libopus voice.opus, or -ar 16000 -ac 1 voice16k.wav for speech models.

Trim, fade, speed

# seconds 1 to 4, with 0.5 s fades in and o
Полный SKILL.md на GitHub

Установить assemble-media в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл assemble-media?

Use to join, trim, mix, subtitle or inspect generated media, make frames and masks for the next generation, or make a simple video from pictures, text or a chart, with ffmpeg, sox, ImageMagick or Pillow.

Как установить скилл assemble-media?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл assemble-media запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить assemble-media с