Created
February 27, 2024 09:11
-
-
Save kdssoftware/5d7d699a144323fa74c1956fc98c25c9 to your computer and use it in GitHub Desktop.
set all undefined audio stream of mp4 movies to english
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 process_file() { | |
movie_file="$1" | |
echo "Checking $movie_file" | |
if ffprobe -v error -show_format -select_streams a:0 -show_streams "$movie_file" | grep "language=und"; then | |
echo "Movie audio undefined: updating $movie_fil ( do not CTRL+C )" # remove .bak file if exist | |
# Create a backup | |
backup_file="${movie_file}.bak" | |
echo "Creating backup $backup_file" | |
cp "$movie_file" "$backup_file" | |
# Change audio language metadata | |
echo "Setting language to english backup.." | |
ffmpeg -y -i "$backup_file" -map 0 -c copy -metadata:s:a:0 language=eng "$movie_file" | |
echo "Audio language changed for $movie_file" | |
rm $backup_file | |
fi | |
} | |
# Find and process MP4 files | |
#find . -iname "*.mp4" -print0 | xargs -0 -I '{}' sh -c 'process_file "$1"' _ '{}' | |
echo "Updating all undefined '*YTS*.mp4' audio streams to english" | |
echo "Starting... (cleanup)" | |
for i in $(find . -iname "*.bak" ); do | |
echo "Removing $i" | |
rm $i | |
done | |
echo "Looking movies with undefined audio stream..." | |
for i in $(find . -iname "*.mp4" ); do | |
process_file "$i" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment