You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scripts/encode_x265_crf18_aac_192k.sh

31 lines
845 B

#!/bin/bash
# Check if argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <file_or_directory>"
exit 1
fi
# Function to process a single file
process_file() {
local input_file="$1"
local output_file="${input_file%.*}_converted.mkv"
echo "Processing: $input_file -> $output_file"
ffmpeg -i "$input_file" -map 0 -pix_fmt yuv420p10le -c:v libx265 -preset slow -crf 18 -c:a aac -b:a 192k -c:s copy -x265-params profile=main10 "$output_file"
}
# If argument is a file, process it
if [ -f "$1" ]; then
process_file "$1"
elif [ -d "$1" ]; then
# If argument is a directory, process all .mkv files in it
for file in "$1"/*.mkv; do
[ -e "$file" ] || continue # Skip if no matching files
process_file "$file"
done
else
echo "Error: $1 is not a valid file or directory."
exit 1
fi