Files
syno_scripts/ffmpeg-convertMP4v5.sh
2022-05-07 22:22:52 +02:00

69 lines
2.3 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# run: sh ffmpeg-convertMP4v5.sh /volume1/video/TV_ts /volume1/video/TV
#v5: notifications, logs
LOG=/volume1/homes/bruno/logs # dossier du fichier .log
JOUR=$(date +"%Y-%m-%d %T") # http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
touch $LOG/ffmpeg.log # création du fichier log
echo $JOUR "Demarrage du script" >> $LOG/ffmpeg.log
# Variables Section
#==============================================================
# list process to monitor in the variable below.
PROGRAM1=ffmpeg
# APPCHK varible checks to see if $PROGRAM1 is running.
APPCHK=$(ps -ea | grep $PROGRAM1 | grep -v grep | wc -l)
#==================================================================
# The if statement below checks to see if the process is running
# with the ps command. If the value is returned as a 0 then
# a message is prompted
if [ $APPCHK -eq 0 ];
then
cd "$1"
for FILE in *;
do
RENAME=$(echo "$FILE" | sed -e 's/[[:blank:]]/_/g');
if [ -e "$RENAME" ];then
echo "">/dev/null;
else
mv "$FILE" "$RENAME";
fi
#on récupère le nom sans extension
NAME=$(echo "$RENAME" | sed 's/\.[^\.]*$//')
#nom des fichiers
INPUT_FILE="$1/$RENAME"
OUTPUT_FILE=$(echo "$2/$NAME.mp4")
#if [ "$NAME" != "@eaDir" -a ! -f "$OUTPUT_FILE" ];
if [ "$NAME" != "@eaDir" ];
then
echo "Conversion du fichier:"
#echo "$INPUT_FILE"
echo " -$OUTPUT_FILE"
echo "$JOUR Debut conversion du fichier $FILE" >> $LOG/ffmpeg.log
#/volume1/homes/bruno/scripts/ffmpeg -i "$INPUT_FILE" -map 0:0 -map 0:1 -c:a aac -strict -2 -async 1 -c:v libx264 -crf 20 -r 25 -s 1920x1080 -aspect 16:9 -qmin 3 -qmax 51 -qdiff 4 -y "$OUTPUT_FILE"
/volume1/homes/bruno/scripts/ffmpeg -i "$INPUT_FILE" -map 0:0 -map 0:1 -c:a aac -b:a 160k -async 1 -c:v libx264 -crf 20 -r 25 -s 1280x720 -aspect 16:9 -y "$OUTPUT_FILE"
mv "$INPUT_FILE" "$2/"
echo "$JOUR Conversion du fichier $NAME.mp4 terminee" >> $LOG/ffmpeg.log
synodsmnotify @administrators "[ffmpeg-convertMP4.sh]" "Conversion du fichier $FILE terminee"
fi
done
else
#echo “$PROGRAM1 is running”
echo "$JOUR $PROGRAM1 est deja actif" >> $LOG/ffmpeg.log
synodsmnotify @administrators "[ffmpeg-convertMP4.sh]" "$PROGRAM1 est deja actif"
fi
echo $JOUR "Fin du script" >> $LOG/ffmpeg.log
exit