Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ffprobe="/volume1/homes/user/ffmpeg/bin/ffprobe"
- ffmpeg="/volume1/homes/user/ffmpeg/bin/ffmpeg"
- ## cleanup by deleting unwanted files
- find "$1" -name "*.txt" -type f -print0 | xargs -0 rm -rf
- find "$1" -name "*.db" -type f -print0 | xargs -0 rm -rf
- find "$1" -name "*.nfo" -type f -print0 | xargs -0 rm -rf
- find "$1" -name "*sample*.mkv" -type f -print0 | xargs -0 rm -rf
- find "$1" -name "*Sample*.mkv" -type f -print0 | xargs -0 rm -rf
- find "$1" -name "*SAMPLE*.mkv" -type f -print0 | xargs -0 rm -rf
- ## go over all MKVs
- find "$1" -name "*.mkv" -type f | while read f
- do
- #echo processing $f
- ## Detect what audio codec is being used:
- audio=$($ffprobe "$f" 2>&1 | sed -n '/Audio:/s/.*: \([a-zA-Z0-9]*\).*/\1/p' | sed 1q)
- aopts="-c:a ac3 -b:a 640k"
- ## Set default video settings:
- vopts="-c:v copy"
- ## Set default subtitle settings:
- sopts="-c:s copy"
- echo "$f -----> audio is $audio" | grep dts
- case "$audio" in
- aac|alac|mp3|mp2|ac3 )
- ## If the audio is one of the MP4-supported codecs
- echo "-----> no processing needed."
- ;;
- "" )
- ## If there is no detected audio stream, don't bother
- echo "-----> can't determine audio, skipping"
- ;;
- * )
- ## anything else, convert
- mv "$f" "$f"-1
- echo -e "\n -----> executing $ffmpeg -y -i $f-1 -map 0 $sopts $vopts $aopts $f"
- $ffmpeg -hwaccel auto -nostdin -y -i "$f"-1 -map 0 $sopts $vopts $aopts "$f"
- fail=$?
- case "$fail" in
- "0" )
- ## put new file in place
- echo "-----> SUCCES"
- rm -rf "$f"-1
- chmod 666 "$f"
- synoindex -D "$f"
- synoindex -A "$f"
- ;;
- * )
- echo "-----> FAIL"
- ## revert back
- rm -rf "$f"
- mv "$f"-1 "$f"
- ;;
- esac
- ;;
- emac
- done
Advertisement
Add Comment
Please, Sign In to add comment