#!/bin/bash
# ============================================================
# ffmpeg.sh — FFmpeg multimedia framework + GStreamer codecs
# ============================================================
# Installs the FFmpeg CLI toolkit, a thumbnailer plugin for
# file managers, and a comprehensive set of GStreamer codec
# plugins.  Together these ensure that the desktop can play,
# convert, and generate thumbnails for virtually any audio or
# video format.
#
# Packages:
#   ffmpeg              — the core FFmpeg encoder/decoder library
#                         and CLI tools (ffmpeg, ffprobe, ffplay)
#   ffmpegthumbnailer   — a thumbnail generator that integrates
#                         with file managers (Thunar, Nautilus,
#                         Dolphin) to show video frame previews
#   gst-libav           — GStreamer plugin wrapping FFmpeg/libav
#                         codecs (H.264, AAC, MP3, etc.)
#   gst-plugins-good    — stable GStreamer plugins (VP8/9, FLAC,
#                         Ogg, ALSA, V4L2, etc.)
#   gst-plugins-bad     — plugins not yet meeting quality bar
#                         but widely used (H.265/HEVC, Opus, AV1,
#                         MPEG-TS, etc.)
#   gst-plugins-ugly    — legally ambiguous plugins (MP3, MPEG-2
#                         video, etc.) that may require patent
#                         licences in some jurisdictions
#
# This is an optional module because the base system includes
# only minimal codec support; users who want full multimedia
# playback should install this module.
# ============================================================

set -euo pipefail
# Load shared logging helpers from the dotfiles lib
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

log "Installing FFmpeg extras (thumbnailer + GStreamer codecs)..."
sudo pacman -S --noconfirm --needed \
    ffmpeg ffmpegthumbnailer \
    gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly

log "FFmpeg extras installed."
