Skill: karlzhu-zxc/media-info (version 1.0.0)

--- name: media-info description: Analyze media files with MediaInfo CLI and compare behavior with ffprobe. Use when inspecting container/codec metadata, extracting width/height/duration/bitrate, troubleshooting files that ffprobe cannot parse, or classifying media by orientation (landscape/portrait). --- # media-info Install and run MediaInfo CLI in non-root environments. ## Quick start 1. Install MediaInfo locally: - `bash scripts/install_mediainfo_local.sh` 2. Verify installation: - `bash scripts/test_mediainfo.sh` 3. Inspect files: - `./vendor/mediainfo/MediaInfo/Project/GNU/CLI/mediainfo <file>` - `./vendor/mediainfo/MediaInfo/Project/GNU/CLI/mediainfo --Output=JSON <file>` ## Workflow ### Install Run `scripts/install_mediainfo_local.sh`. - Download MediaInfo source archive - Build CLI locally - Place binary at [REDACTED_SECRET] ### Extract metadata Use plain output for human reading and JSON output for automation. ### Classify orientation Use Width/Height (and Rotation when present): - landscape: effective width >= effective height - portrait: effective width < effective height When Rotation is 90/270, swap width and height before classification. ## Notes - Do not require sudo. - Prefer MediaInfo for files where ffprobe fails but container data still exists.

path: scripts/install_mediainfo_local.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENDOR_DIR="$ROOT_DIR/vendor"
SRC_DIR="$VENDOR_DIR/mediainfo-src"
OUT_DIR="$VENDOR_DIR/mediainfo"

MEDIAINFO_VERSION="${MEDIAINFO_VERSION:-0.7.94}"
MEDIAINFO_URL="${MEDIAINFO_URL:-https://mediaarea.net/download/binary/mediainfo/${MEDIAINFO_VERSION}/MediaInfo_CLI_${MEDIAINFO_VERSION}_GNU_FromSource.tar.bz2}"

BIN="$OUT_DIR/MediaInfo/Project/GNU/CLI/mediainfo"

if [[ -x "$BIN" ]]; then
  echo "[ok] mediainfo already exists: $BIN"
  "$BIN" --Version || true
  exit 0
fi

mkdir -p "$SRC_DIR" "$OUT_DIR"
ARCHIVE="$SRC_DIR/mediainfo-${MEDIAINFO_VERSION}.tar.bz2"
EXTRACTED="$SRC_DIR/MediaInfo_CLI_GNU_FromSource"

if [[ ! -f "$ARCHIVE" ]]; then
  echo "[info] downloading $MEDIAINFO_URL"
  curl -fL "$MEDIAINFO_URL" -o "$ARCHIVE"
fi

rm -rf "$EXTRACTED"
mkdir -p "$EXTRACTED"
tar -xjf "$ARCHIVE" -C "$SRC_DIR"

pushd "$EXTRACTED" >/dev/null
bash ./CLI_Compile.sh
popd >/dev/null

rm -rf "$OUT_DIR"
mkdir -p "$VENDOR_DIR"
cp -a "$EXTRACTED" "$OUT_DIR"

if [[ ! -x "$BIN" ]]; then
  echo "[error] build completed but binary not found: $BIN" >&2
  exit 1
fi

echo "[ok] installed mediainfo: $BIN"
"$BIN" --Version || true


path: scripts/test_mediainfo.sh
content: #!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BIN="$ROOT_DIR/vendor/mediainfo/MediaInfo/Project/GNU/CLI/mediainfo"
TMP_DIR="$ROOT_DIR/tmp"
WAV="$TMP_DIR/test-tone.wav"

if [[ ! -x "$BIN" ]]; then
  echo "[error] mediainfo binary not found. run scripts/install_mediainfo_local.sh first" >&2
  exit 1
fi

mkdir -p "$TMP_DIR"
WAV_PATH="$WAV" python3 - <<'PY'
import math, struct, wave, os
wav = os.environ.get('WAV_PATH')
fr = 44100
sec = 1
with wave.open(wav, 'w') as w:
    w.setnchannels(1)
    w.setsampwidth(2)
    w.setframerate(fr)
    for i in range(fr * sec):
        v = int(32767 * math.sin(2 * math.pi * 440 * i / fr))
        w.writeframes(struct.pack('<h', v))
PY

"$BIN" --Version || true
"$BIN" "$WAV" | sed -n '1,30p'

echo "[ok] smoke test passed: $WAV"


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