-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic script to convert sequence of photos in a mp4 video
- Loading branch information
1 parent
03af03b
commit bf56a10
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|