Skip to content

Commit

Permalink
More error handling on video encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
helioloureiro committed Jun 26, 2024
1 parent 6ef61dc commit 2faa343
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions render-video-from-gopro-photos.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#! /usr/bin/env bash

die() {
echo "$1" >&2
exit 1
}

counter=0
for img in G[0-9]*.JPG
do
Expand All @@ -17,15 +22,18 @@ 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
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 || \
die "Failed to render 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
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i output.mp4 -c:v h264_nvenc -vf scale=1920:1440 -c:a copy output_1920x1440.mp4 || \
die "Failed to render 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
ffmpeg -hwaccel cuda -i output_1920x1440.mp4 -c:v h264_nvenc -vf "crop=1920:1080:0:180" output_1080p.mp4 || \
die "Failed to render output_1080p.mp4"
;;
Darwin)
Darwin)
echo "Merging images into single video file: output.mp4"
ffmpeg -r 1 -i G%06d.JPG -c:v h264_videotoolbox -b:v 5M -pix_fmt yuv420p output.mp4
die "Failed to render output.mp4"
echo "Resizing video to 1920x1440: output_1920x1440.mp4"
ffmpeg -hwaccel auto -i output.mp4 -c:v h264_videotoolbox -q:v 90 -vf scale=1920:1440 -c:a copy output_1920x1440.mp4
echo "Cropping file video as 1080p: output_1080p.mp4"
Expand Down
1 change: 1 addition & 0 deletions restart_mouse.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/bash

MOUSE_PRODUCT="G203 Prodigy Gaming Mouse"
MOUSE_PRODUCT="USB Optical Mouse"
HUB_PRODUCT="USB2.0 Hub"

die() {
Expand Down

0 comments on commit 2faa343

Please sign in to comment.