#!/bin/sh
# CI 公共步骤：安装 ffmpeg
set +e
if command -v ffmpeg > /dev/null 2>&1; then
  echo "ffmpeg already installed: $(ffmpeg -version | head -1)"
  exit 0
fi
if command -v apt-get > /dev/null 2>&1; then
  apt-get update -qq && apt-get install -y -qq ffmpeg
elif command -v yum > /dev/null 2>&1; then
  yum install -y -q epel-release 2>/dev/null
  yum install -y -q ffmpeg 2>/dev/null
  if [ $? -ne 0 ] && command -v dnf > /dev/null 2>&1; then
    dnf install -y -q --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm 2>/dev/null
    dnf install -y -q ffmpeg 2>/dev/null
  fi
elif command -v dnf > /dev/null 2>&1; then
  dnf install -y -q ffmpeg 2>/dev/null
fi
if command -v ffmpeg > /dev/null 2>&1; then
  echo "ffmpeg installed successfully: $(ffmpeg -version | head -1)"
else
  echo "Warning: ffmpeg installation failed or not available, some tests may be skipped"
fi
