From c9c9fda6ed2d2c0a5b2f060aa43fbe2b1f57d7e3 Mon Sep 17 00:00:00 2001 From: sc-idevops Date: Sat, 20 Jan 2024 19:06:00 -0500 Subject: [PATCH] ensure that ffmpeg completes successfully before removing source file --- scripts/server_bin/fps_cut.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/server_bin/fps_cut.sh b/scripts/server_bin/fps_cut.sh index 17a3fe0..02d3846 100755 --- a/scripts/server_bin/fps_cut.sh +++ b/scripts/server_bin/fps_cut.sh @@ -1,10 +1,9 @@ #!/bin/bash for i in `fdfind video.mp4`; do - if [ $(ffprobe -show_streams $i 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') -gt 30 ]; then - snap run ffmpeg -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i "$i" -c:a copy -c:v h264_nvenc -filter:v fps=30 "${i}_30.mp4" - rm "$i" - mv "${i}_30.mp4" "$i" + if [[ (( $(ffprobe -show_streams $i 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') > 30 )) ]]; then + snap run ffmpeg -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i "$i" -c:a copy -c:v h264_nvenc -filter:v fps=30 "${i}_30.mp4" && \ + rm "$i" ; mv "${i}_30.mp4" "$i" fi echo "no edit for $i" done