Convert all MKV files in the current directory and make them mp4 compatible with Ipad
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 | |
# Iterate through all .mkv files in the current directory | |
for file in *.mkv; do | |
if [[ -f "$file" ]]; then | |
# Remove spaces and emoji characters from the file name | |
new_name=$(echo "$file" | sed -e 's/ /_/g' -e 's/[^[:alnum:]._\-]//g') | |
if [[ "$new_name" != "$file" ]]; then | |
mv "$file" "$new_name" | |
echo "Renamed file: $file -> $new_name" | |
file="$new_name" | |
fi | |
# Convert the file to iPad-compatible format using FFmpeg | |
output_file="${file%.*}.mp4" | |
ffmpeg -i "$file" -c:v h264 -crf 23 -preset medium -c:a aac -b:a 128k "$output_file" | |
echo "Converted file: $file -> $output_file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment