Last active
June 12, 2021 08:15
-
-
Save tomgrv/a484d05fd70a69352100b08b824b9c47 to your computer and use it in GitHub Desktop.
Synology Video Station Convert EAC to AAC (needs docker package to be installed)
This file contains hidden or 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/sh | |
if [ -z "$1" ] | |
then | |
dir=/var/services/video | |
elif [ -d "$1" ] | |
then | |
dir=$(readlink -e $1) | |
else | |
echo "Folder <$1> do not exits" | |
exit | |
fi | |
echo "Cleanup <$dir>..." | |
find "$dir" -type f ! -path '*@ea*' ! -iname '*.mkv' ! -iname '*.mp4' ! -iname '*.avi' ! -iname '*.vsmeta' ! -iname '*.converted' ! -iname '*.sub' ! -iname '*.srt' ! -iname '*.flv' ! -iname '*.sh' ! -iname '*.mpg' ! -iname '*.mpeg' | while read f | |
do | |
echo "Processing <$f>..." | |
rm -f "$f" | |
done | |
find "$dir" -type d ! -path '*@ea*' | while read d | |
do | |
if [ $(ls -A "$d" | wc -l) -eq 0 ] | |
then | |
echo "directory <$d> is empty, removing" | |
rm -rf "$d" | |
fi | |
done | |
echo "Done!" |
This file contains hidden or 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/sh | |
if [ -z "$1" ] | |
then | |
echo "Use default 'video' share" | |
dir=$(synoshare --get video | grep -i path | sed 's/.*\[\([^]]*\)\].*/\1/g') | |
elif [ -d "$1" ] | |
then | |
echo "Use specified folder" | |
dir=$(readlink -e $1) | |
else | |
echo "Folder <$1> do not exits" | |
exit | |
fi | |
echo "Convert eac3 files in <$dir>..." | |
find "$dir" -type f -name '*eac3*' ! -name '*.vsmeta' ! -name '*.converted' | while read f | |
do | |
echo "Processing $f..." | |
rf=$(realpath --relative-to="$dir" "$f") | |
ow=$(stat -c '%U:%G' "$f") | |
cf=$(echo $rf | sed 's/eac/aac/') | |
docker run --rm --device /dev/dri:/dev/dri -v "$dir":/mnt jrottenberg/ffmpeg:4.2-alpine -y -i "/mnt/$rf" -map 0 -c:v copy -c:a libfdk_aac -b:a 384k -c:s copy "/mnt/$cf" | |
if [ -f "$dir/$cf" ] | |
then | |
chown $ow "$dir/$cf" | |
mv "$dir/$rf" "$dir/$rf.converted" | |
if [ -f "$dir/$rf.vsmeta" ] | |
then | |
mv "$dir/$rf.vsmeta" "$dir/$cf.vsmeta" | |
fi | |
fi | |
done | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment