initial commit

This commit is contained in:
2026-03-24 18:11:39 -06:00
commit 352c8e0b73
11 changed files with 2576 additions and 0 deletions
+162
View File
@@ -0,0 +1,162 @@
#!/usr/bin/env bash
# =============================================================================
# SWF Converter — Fedora Setup Script
# =============================================================================
# Run with: bash install.sh
# =============================================================================
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERR]${NC} $*"; }
echo -e "\n${BOLD}SWF → MP4 Converter Setup (Fedora)${NC}"
echo "=================================================="
# --- System dependencies ---
info "Installing system packages via dnf..."
sudo dnf install -y \
ffmpeg \
xdotool \
ImageMagick \
scrot \
python3 \
python3-pip \
python3-tkinter \
xorg-x11-server-Xvfb
success "System packages installed."
# --- Python dependencies ---
info "Installing Python packages..."
pip3 install --user pillow
success "Python packages installed."
# --- Ruffle ---
echo ""
info "Checking for Ruffle..."
RUFFLE_BIN="$HOME/.local/bin/ruffle"
if command -v ruffle &>/dev/null || [ -f "$RUFFLE_BIN" ]; then
success "Ruffle found: $(command -v ruffle 2>/dev/null || echo $RUFFLE_BIN)"
else
warn "Ruffle not found. Attempting to download latest release..."
mkdir -p "$HOME/.local/bin"
# Detect arch
ARCH=$(uname -m)
case "$ARCH" in
x86_64) RUFFLE_ARCH="x86_64-linux" ;;
aarch64) RUFFLE_ARCH="aarch64-linux" ;;
*)
error "Unknown architecture: $ARCH"
echo "Download Ruffle manually from: https://github.com/ruffle-rs/ruffle/releases"
echo "Place the binary at: $RUFFLE_BIN"
RUFFLE_ARCH=""
;;
esac
if [ -n "$RUFFLE_ARCH" ]; then
# Get latest release URL
RELEASE_URL=$(curl -s https://api.github.com/repos/ruffle-rs/ruffle/releases/latest \
| grep "browser_download_url" \
| grep "$RUFFLE_ARCH" \
| grep -v ".sha256" \
| head -1 \
| cut -d '"' -f 4)
if [ -n "$RELEASE_URL" ]; then
info "Downloading: $RELEASE_URL"
TMP_DIR=$(mktemp -d)
curl -L "$RELEASE_URL" -o "$TMP_DIR/ruffle.tar.gz"
tar -xzf "$TMP_DIR/ruffle.tar.gz" -C "$TMP_DIR"
RUFFLE_EXE=$(find "$TMP_DIR" -name "ruffle" -type f | head -1)
if [ -n "$RUFFLE_EXE" ]; then
cp "$RUFFLE_EXE" "$RUFFLE_BIN"
chmod +x "$RUFFLE_BIN"
rm -rf "$TMP_DIR"
success "Ruffle installed to $RUFFLE_BIN"
else
error "Could not find ruffle binary in archive."
echo "Download manually: https://github.com/ruffle-rs/ruffle/releases"
fi
else
error "Could not find Ruffle release for $RUFFLE_ARCH."
echo "Download manually: https://github.com/ruffle-rs/ruffle/releases"
fi
fi
fi
# Ensure ~/.local/bin is on PATH
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
warn "~/.local/bin is not in your PATH."
echo " Add this to your ~/.bashrc or ~/.zshrc:"
echo ' export PATH="$HOME/.local/bin:$PATH"'
fi
# --- Lightspark (optional fallback) ---
echo ""
info "Lightspark (optional fallback emulator)..."
if command -v lightspark &>/dev/null; then
success "Lightspark found."
else
warn "Lightspark not found. Optional — only needed if Ruffle can't run a SWF."
echo " To install: sudo dnf install lightspark"
echo " Or build from source: https://github.com/lightspark/lightspark"
fi
# --- Verify ffmpeg capabilities ---
echo ""
info "Verifying FFmpeg x11grab support..."
if ffmpeg -f x11grab -i :0 -t 0.1 /dev/null 2>&1 | grep -q "x11grab"; then
warn "x11grab reported an issue — ensure a display (:0) is available when recording."
else
success "FFmpeg x11grab available."
fi
# --- Verify PulseAudio ---
info "Verifying PulseAudio..."
if pactl info &>/dev/null; then
success "PulseAudio running."
else
warn "PulseAudio not running. Audio recording may fail."
echo " Start with: pulseaudio --start"
echo " Or use '--no-audio' flag when converting (set audio: false in config)."
fi
# --- Virtual display setup (for headless/server use) ---
echo ""
info "Virtual display (Xvfb) — for headless environments only..."
echo " If running on a server without a display, start Xvfb with:"
echo " Xvfb :99 -screen 0 1024x768x24 &"
echo " export DISPLAY=:99"
echo " Then run conversions normally."
# --- Final check ---
echo ""
echo -e "${BOLD}Setup complete! Quick-start:${NC}"
echo ""
echo " # Inspect a SWF file:"
echo " python3 convert.py --inspect my.swf"
echo ""
echo " # Generate a config template:"
echo " python3 convert.py --generate-config *.swf"
echo ""
echo " # Map interaction points interactively:"
echo " python3 map_interactions.py my.swf"
echo ""
echo " # Convert a single SWF:"
echo " python3 convert.py my.swf"
echo ""
echo " # Convert a directory of SWFs:"
echo " python3 convert.py ./swf_files/ -o ./output/"
echo ""