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

54 lines
1.5 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-convertMP4v4.sh /volume1/video/TV_ts /volume1/video/TV
# Variables Section
#==============================================================
# list process to monitor in the variable below.
#PROGRAM1=$1
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
echo$PROGRAM1 may be down”
cd "$1"
#rename 's/[[:blank:]]/_/g' *
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 "$INPUT_FILE"
echo "$OUTPUT_FILE"
#echo "$2/"
/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"
mv "$INPUT_FILE" "$2/"
fi
done
else
echo$PROGRAM1 is running”
fi
exit