-
-
Save Senya247/849eae98bee1e14bf92fcf193cf9fdf3 to your computer and use it in GitHub Desktop.
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 | |
find . -name '*.temptrans*' -delete | |
folder_path="." | |
IFS=$'\n' | |
while true; do | |
files=$(find "$folder_path" -type f -name "*.mp4" -o -name "*.mkv" -o -name "*.ts") | |
for file in $files; do | |
if lsof -w "$file" > /dev/null; then | |
echo "$file busy" | |
sleep 2 | |
else | |
if [[ $(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 ""$file"") != "hevc" ]]; then | |
ffmpeg -hide_banner -i "$file" -c:v libx265 -crf 28 -c:a aac -b:a 128k "${file%.*}.h265.temptrans.mp4" | |
if [ $? -eq 0 ]; then | |
mv "${file%.*}.h265.temptrans.mp4" "${file%.*}.h265.mp4" | |
rm "$file" | |
fi | |
fi | |
fi | |
done | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment