diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..24a8e87 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index a4ba104..b0209fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Image files +image/* *.img *.img.xz diff --git a/usr/local/bin/convert-to-video.sh b/usr/local/bin/convert-to-video.sh new file mode 100755 index 0000000..0f626ae --- /dev/null +++ b/usr/local/bin/convert-to-video.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -euo pipefail + +die() { + echo "$*" >&2 + exit 1 +} + +usage() { + cat <<'EOF' >&2 +Usage: convert-to-video.sh /path/to/audio.file +Creates a slideshow video from stormux images and the provided audio. +EOF + exit 1 +} + +require_commands() { + for cmd in "$@"; do + command -v "$cmd" >/dev/null 2>&1 || die "Missing dependency: $cmd" + done +} + +locate_images() { + local candidate="." + local have_all=true + + for i in 1 2 3 4 5; do + [ -f "$candidate/stormux${i}.png" ] || have_all=false + done + + if [ "$have_all" = true ]; then + printf '%s\n' "$candidate" + return + fi + + candidate="/usr/share/stormux/slideshow" + for i in 1 2 3 4 5; do + [ -f "$candidate/stormux${i}.png" ] || die "Missing image: $candidate/stormux${i}.png" + done + + printf '%s\n' "$candidate" +} + +detect_container() { + local audio_file="$1" + local codec + + codec="$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of csv=p=0 "$audio_file" || true)" + case "$codec" in + aac|mp3) echo "mp4" ;; + *) echo "mkv" ;; + esac +} + +build_video() { + local audio_file="$1" + local image_dir="$2" + local container="$3" + + ffmpeg -y \ + -stream_loop -1 -framerate 1/35 -start_number 1 -i "$image_dir/stormux%d.png" \ + -i "$audio_file" \ + -map 0:v:0 -map 1:a:0 \ + -c:v libx264 -crf 18 -preset veryfast -r 30 -pix_fmt yuv420p \ + -c:a copy \ + -shortest \ + "$4" +} + +[ "$#" -eq 1 ] || usage + +audio="$1" +[ -f "$audio" ] || die "Audio file not found: $audio" + +require_commands ffmpeg ffprobe + +image_dir="$(locate_images)" +container="$(detect_container "$audio")" +base="$(basename "$audio")" +name="${base%.*}" +output="${name}.${container}" + +build_video "$audio" "$image_dir" "$container" "$output" + +echo "Wrote $output" diff --git a/usr/share/stormux/slideshow/stormux1.png b/usr/share/stormux/slideshow/stormux1.png new file mode 100644 index 0000000..8e64533 --- /dev/null +++ b/usr/share/stormux/slideshow/stormux1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4f54b4f4555bbad3d01ff406233eb12cecdc4382a3a05e44ca3f6ddaf756b39 +size 2537313 diff --git a/usr/share/stormux/slideshow/stormux2.png b/usr/share/stormux/slideshow/stormux2.png new file mode 100644 index 0000000..d32dc76 --- /dev/null +++ b/usr/share/stormux/slideshow/stormux2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9886aca9f0d3ef75c7b24689c98624ca45c2656b6c552ef1662d4aaed6835d65 +size 2561301 diff --git a/usr/share/stormux/slideshow/stormux3.png b/usr/share/stormux/slideshow/stormux3.png new file mode 100644 index 0000000..1baa5d3 --- /dev/null +++ b/usr/share/stormux/slideshow/stormux3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c87fc00ff97c15f597874cf069f304b1aadcfcfbf3fd86d3ee184fa7773e7de9 +size 2564105 diff --git a/usr/share/stormux/slideshow/stormux4.png b/usr/share/stormux/slideshow/stormux4.png new file mode 100644 index 0000000..602de96 --- /dev/null +++ b/usr/share/stormux/slideshow/stormux4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f793d98d810e8b91860211fd570191b3b433ff3e1b8dac95c6fe9b15b78aca20 +size 2541631 diff --git a/usr/share/stormux/slideshow/stormux5.png b/usr/share/stormux/slideshow/stormux5.png new file mode 100644 index 0000000..e700cf6 --- /dev/null +++ b/usr/share/stormux/slideshow/stormux5.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b02fab4fe7a46056cf9392fe12f4ae5e8056bd526e25733979de497a1e08c466 +size 2337117