1st commit
This commit is contained in:
84
ffmpeg-convertMP4.sh
Normal file
84
ffmpeg-convertMP4.sh
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
# run: sh ffmpeg-convertMP4v6.sh /volume1/video/TV_ts /volume1/video/TV
|
||||
#v5: notifications, logs
|
||||
#v6: modif date dans les logs
|
||||
#v7 supprime ( GR1_B SMR6 Nat CNH Multi4 NTN MHD7 )
|
||||
|
||||
LOG=/volume1/homes/bruno/logs # dossier du fichier .log
|
||||
ENREGISTREMENTS=/volume1/video/TV_2
|
||||
TABLEAU=( GR1_B SMR6 Nat CNH Multi4 NTN MHD7 )
|
||||
# http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/
|
||||
timestamp()
|
||||
{
|
||||
date +"%d-%m-%Y %T"
|
||||
}
|
||||
|
||||
# création du fichier log
|
||||
touch $LOG/ffmpeg.log
|
||||
echo $(timestamp) "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
|
||||
|
||||
#on supprime les espaces dans les noms de fichiers
|
||||
# on supprime ( GR1_B SMR6 Nat CNH Multi4 NTN MHD7 )
|
||||
#RENAME=$(echo "$FILE" | sed -e 's/[[:blank:]]/_/g');
|
||||
RENAME=$(echo "$FILE" | sed -e '{s/[[:blank:]]/_/g;s/(\(GR1_B\|SMR6\|Nat\|CNH\|Multi4\|NTN\|MHD7\))//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: $OUTPUT_FILE"
|
||||
|
||||
#echo "$JOUR Debut conversion du fichier $FILE" >> $LOG/ffmpeg.log
|
||||
echo "$(timestamp) 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"
|
||||
#les originaux sont déplacés dans $ENREGISTREMENTS
|
||||
mv "$INPUT_FILE" "$ENREGISTREMENTS/"
|
||||
|
||||
#echo "$JOUR Conversion du fichier $NAME.mp4 terminee" >> $LOG/ffmpeg.log
|
||||
echo "$(timestamp) 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
|
||||
echo "$(timestamp) $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
|
||||
echo "$(timestamp) Fin du script" >> $LOG/ffmpeg.log
|
||||
exit
|
||||
Reference in New Issue
Block a user