diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-02-28 13:05:06 -0600 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-02-28 13:05:06 -0600 |
| commit | 2fd089ea758d376e862eba3cdf09c2c6bf049b16 (patch) | |
| tree | 8027f948190190ebbd82ee24fe95d50f0a33f452 /video | |
| parent | 69e2cf6f2921e5e22697ccc5b97ad3e01b71aa7c (diff) | |
| download | scripts-master.tar.xz scripts-master.zip | |
Diffstat (limited to 'video')
| -rwxr-xr-x | video/slideshow | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/video/slideshow b/video/slideshow index 4cd1f61..0d46038 100755 --- a/video/slideshow +++ b/video/slideshow @@ -1,15 +1,50 @@ #!/bin/sh -cat "$@" | ffmpeg -y \ - -framerate 0.20 -loop 1 \ - -f image2pipe \ +# settings +ms_per_frame=5000 +resolution=1920x1080 +output=output.mkv + +# dependency check +! command -v ffmpeg > /dev/null && echo "Missing dependency: ffmpeg" && exit 1 +! command -v magick > /dev/null && echo "Missing dependency: magick" && exit 1 + +# calc runtime (for fun) +intdiv() { echo $(($1 / $2)).$((($1 % $2) * 1000 / $2)); } # calc decimal using integer arithmetic +hms_from_ms() { printf '%02d:%02d:%02d' $(($1 / 3600000)) $((($1 % 3600000) / 60000)) $((($1 % 60000) / 1000)); } +ctime() { t=$(date +%s) && echo $(( t * 1000 )); } +framerate=$(intdiv 1000 $ms_per_frame) +runtime=$(hms_from_ms $((ms_per_frame * $#))) + +echo "Creating a slideshow ($output) consisting of $# images at $(intdiv $ms_per_frame 1000) seconds per frame for a total runtime of approximately $runtime" +count=0 +stime=$(ctime) + +# slideshow +for img in "$@"; do + count=$((count + 1)) + etime=$(ctime) + elapsed=$(hms_from_ms $(( etime - stime ))) + printf '[%0*d/%d] (elapsed %s) %s\n' ${##} $count $# $elapsed "$img" >&2 + + magick "$img" \ + -auto-orient \ + -resize $resolution \ + -background black \ + -gravity center \ + -extent $resolution \ + -depth 8 \ + rgb:- +done | ffmpeg -y -v error \ + -f rawvideo \ + -video_size $resolution \ + -pixel_format rgb24 \ + -framerate $framerate \ + -probesize 32 \ + -analyzeduration 0 \ -i - \ - -c:v libx264 -quality quality -tune stillimage \ - -qmin 12 -qmax 28 -qdiff 16 \ - -vf \ - fps=1,\ - framerate=25:\ - interp_start=0:\ - interp_end=255:\ - scene=100 \ - -metadata "title"="$(pwd | sed "s/.*\///")" \ - output.mkv + -vf "fps=1,framerate=30:interp_start=0:interp_end=255:scene=100" \ + -c:v libx264 \ + -crf 22 \ + -preset ultrafast \ + -tune stillimage \ + $output |
