Last active
January 11, 2023 02:48
-
-
Save mike-weiner/de0b71e4bd30c2d17fc59dcd4318a8d3 to your computer and use it in GitHub Desktop.
A bash script that uses FFmpeg to crop a video.
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 | |
# Function that will print requirements if the user passes in the -help flag as the first argument. | |
function help | |
{ | |
echo "Parameters are: " | |
echo " <filename>: The full filename of the video that you want to crop." | |
} | |
# Check for '-help' flag. | |
if [ "$1" == "-help" ]; | |
then | |
help | |
exit 0 | |
fi | |
# Check that the user actually passed in a filename. | |
if [ $# -eq 0 ] | |
then | |
echo "Error: You must supply the filename of the video that you want to crop." | |
exit 1 | |
fi | |
# Make the directory that will store cropped videos (if it exists). | |
mkdir -p ./cropped/ | |
# Store the filename that the user passed in. | |
# This is the file that will be cropped. | |
file_name=$1 | |
ffmpeg -i ${file_name} -vf crop=iw/3:ih:2*iw/3:iw -c:a copy ./cropped/cropped-${file_name} && echo "===Succeeded===" || echo "===Failed===" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment