Created
December 4, 2023 07:18
-
-
Save urklc/d7eed2367a240a034204061a023b94a7 to your computer and use it in GitHub Desktop.
scale_video_sh
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
#!/bin/bash | |
scaleFactor=0.5 | |
for file in *.mp4; do | |
# Extract original dimensions | |
width=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=p=0 "${file}") | |
height=$(ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=p=0 "${file}") | |
# Calculate new dimensions | |
newWidth=$(echo "$width * $scaleFactor" | bc) | |
newHeight=$(echo "$height * $scaleFactor" | bc) | |
# Resize video | |
ffmpeg -i "${file}" -vf "scale=${newWidth}:${newHeight}" "resized_${file}" | |
rm "${file}" | |
mv "resized_${file}" "${file}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment