From bf56a10382b25b5dd49433d832576bf5a23b5633 Mon Sep 17 00:00:00 2001 From: Helio Loureiro <helio@loureiro.eng.br> Date: Mon, 25 Dec 2023 18:58:08 +0100 Subject: [PATCH] Generic script to convert sequence of photos in a mp4 video --- photos-to-video.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 photos-to-video.sh diff --git a/photos-to-video.sh b/photos-to-video.sh new file mode 100755 index 0000000..6a1e396 --- /dev/null +++ b/photos-to-video.sh @@ -0,0 +1,29 @@ +#! /usr/bin/env bash + +counter=0 +for img in [0-9]*.jpg +do + serial=$(printf "%06d" $counter) + new_name="G${serial}.JPG" + counter=$(expr $counter + 1) + if [ -f "$new_name" ]; then + echo "$new_name already exists" + continue + fi + echo "$img => $new_name" + mv $img $new_name +done + +case $(uname -s) in + Linux) + echo "Merging images into single video file: output.mp4" + ffmpeg -hwaccel cuda -hwaccel_output_format cuda -r 1 -i G%06d.JPG -c:v h264_nvenc -b:v 5M -pix_fmt cuda output.mp4 + echo "Resizing video to 1920x1440: output_1920x1440.mp4" + ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i output.mp4 -c:v h264_nvenc -vf scale=1920:1440 -c:a copy output_1920x1440.mp4 + echo "Cropping file video as 1080p: output_1080p.mp4" + ffmpeg -hwaccel cuda -i output_1920x1440.mp4 -c:v h264_nvenc -vf "crop=1920:1080:0:180" output_1080p.mp4 + ;; + Darwin) + ffmpeg -r 1 -i G%06d.JPG -c:v h264_videotoolbox -b:v 5M -pix_fmt yuv420p output.mp4 +esac +