kekePower/toprores
zrep install kekePower/toprores
Version: 1.2.6
Back to script
# Description: Script to convert video files to the ProRes format using ffmpeg
# License: MIT
# Version: 1.2.6
toprores() {
# Check if ~/.toprores config file exists
if [[ ! -f ~/.toprores ]]; then
echo "What do you want to name the output directory for your ProRes videos?"
read outputDirName
echo $outputDirName > ~/.toprores
else
outputDirName=$(cat ~/.toprores)
fi
# Ensure the output directory exists in the current directory
mkdir -p "./$outputDirName"
# Function to convert a single file
convert_file() {
local inputFile=$1
local outputFile="./$outputDirName/${inputFile%.*}.mov"
ffmpeg -i "$inputFile" -c:v prores_ks -profile:v 3 -vendor apl0 -bits_per_mb 8000 -pix_fmt yuv422p10le -c:a pcm_s16le "$outputFile"
}
# Track if any files are converted
local filesConverted=0
# If no arguments are provided, convert all video files in the current directory
if [[ $# -eq 0 ]]; then
for file in *.{mp4,mkv,avi,mov,MP4,MKV,AVI,MOV}(N); do
if [[ -f "$file" ]]; then
convert_file "$file"
((filesConverted++))
fi
done
elif [[ $# -eq 1 ]]; then
# If the argument is a file, convert it
if [[ -f $1 ]]; then
convert_file "$1"
((filesConverted++))
# If the argument is not a file, assume it is an extension and convert all files of that type
else
for file in *.$1(N); do
if [[ -f "$file" ]]; then
convert_file "$file"
((filesConverted++))
fi
done
fi
fi
# Check if any files were converted
if [[ $filesConverted -eq 0 ]]; then
echo "No video files found for conversion."
else
echo "$filesConverted file(s) converted successfully."
fi
}