This commit is contained in:
www-data 2024-08-01 17:19:19 -03:00 committed by Gabriel Carneiro
parent d1138fa87e
commit 195e88a079
1 changed files with 67 additions and 34 deletions

View File

@ -1,63 +1,55 @@
#!/bin/sh #!/bin/sh
SRC=collections/_aulas SRC=collections/_aulas
SCRIPT=script/ # SCRIPT=script/
TMP=tmp/ SCRIPT=/var/www/src/AliceClass/script/
# TMP=tmp
TMP=$(mktemp -d)
ASSETS="$TMP/assets"
PARAM="scale=1920:1080: force_original_aspect_ratio=decrease: eval=frame,pad=1920:1080: -1:-1:color=black" PARAM="scale=1920:1080: force_original_aspect_ratio=decrease: eval=frame,pad=1920:1080: -1:-1:color=black"
mkdir -p ./${TMP} process_video () {
NAME=$1
AUTHOR=$2
INPUT=$3
AULA=$4
OUTPUT=$5
# #################################### # no output path
# Creating the credits clip if [ -z "$OUTPUT" ]; then
# #################################### OUTPUT="$ASSETS/videos/${NAME}.mp4"
#if test ${TMP}/tmp-credits.mkv -ot ${SCRIPT}/credits.svg ; then fi
echo "########################################"
echo "# Gerando o tmp-credits.mkv"
echo "########################################"
ffmpeg -y -loop 1 -i ${SCRIPT}/credits.svg -i ${SCRIPT}/credits.wav -shortest ${TMP}/tmp-credits.mkv
#fi
# ####################################
# Creating dest dir
# ####################################
mkdir -p ./assets/thumbs
mkdir -p ./assets/videos
for aula in ./${SRC}/*.md; do
# ####################################
# Getting parameters from aulas
# ####################################
NAME="$(basename "${aula}" .md)"
AUTHOR=$(grep "^author: " "${aula}" | sed -e 's/author: //g')
INPUT="${SRC}/${NAME}.mkv"
echo "########################################" echo "########################################"
echo "# Aula: ${aula}" echo "# Aula: ${AULA}"
echo "# Author: ${AUTHOR}" echo "# Author: ${AUTHOR}"
echo "# Input: ${INPUT}" echo "# Input: ${INPUT}"
echo "# Src: ${SRC}" echo "# Src: ${SRC}"
echo "# Dest: ${OUTPUT}"
echo "# Name: ${NAME}" echo "# Name: ${NAME}"
echo "# Script Path: ${SCRIPT}" echo "# Script Path: ${SCRIPT}"
echo "########################################" echo "########################################"
# exit
# #################################### # ####################################
# Creating the thumbnail if does not exist # Creating the thumbnail if does not exist
# #################################### # ####################################
if test ! -f "./assets/thumbs/${NAME}.jpg" ; then if test ! -f "$ASSETS/thumbs/${NAME}.jpg" ; then
ffmpeg -y -i "${INPUT}" -vframes 1 -an -s 400x222 -ss 30 "./assets/thumbs/${NAME}.jpg" ffmpeg -y -i "${INPUT}" -vframes 1 -an -s 400x222 -ss 30 "$ASSETS/thumbs/${NAME}.jpg"
fi fi
# #################################### # ####################################
# if output exist, continue # if output exist, continue
# #################################### # ####################################
if test -f "./assets/videos/${NAME}.mp4" ; then if test -f "$ASSETS/videos/${NAME}.mp4" ; then
continue continue
fi fi
# #################################### # ####################################
# Creating the intro clip # Creating the intro clip
# #################################### # ####################################
sed "s/nomenome/$AUTHOR/g" ${SCRIPT}/intro.svg | sed "s/curso/${NAME}/g" > ${TMP}/tmp-intro.svg # sed "s/nomenome/$AUTHOR/g" ${SCRIPT}/intro.svg | sed "s/curso/${NAME}/g" > ${TMP}/tmp-intro.svg
sed "s/nomenome/$AUTHOR/g; s/curso/${NAME}/g" ${SCRIPT}/intro.svg > ${TMP}/tmp-intro.svg
ffmpeg -y -loop 1 -i ${TMP}/tmp-intro.svg -i ${SCRIPT}/intro.wav -shortest ${TMP}/tmp-intro.mkv ffmpeg -y -loop 1 -i ${TMP}/tmp-intro.svg -i ${SCRIPT}/intro.wav -shortest ${TMP}/tmp-intro.mkv
# ################################################### # ###################################################
@ -94,7 +86,48 @@ for aula in ./${SRC}/*.md; do
-vcodec libx264 \ -vcodec libx264 \
-pix_fmt yuv420p \ -pix_fmt yuv420p \
-vsync 2 \ -vsync 2 \
"./assets/videos/${NAME}.mp4" "$OUTPUT"
done }
rm -f ${tmp}
# mkdir -p ./${TMP}
# ####################################
# Creating the credits clip
# ####################################
#if test ${TMP}/tmp-credits.mkv -ot ${SCRIPT}/credits.svg ; then
echo "########################################"
echo "# Gerando o tmp-credits.mkv"
echo "########################################"
ffmpeg -y -loop 1 -i ${SCRIPT}/credits.svg -i ${SCRIPT}/credits.wav -shortest ${TMP}/tmp-credits.mkv
#fi
# ####################################
# Creating dest dir
# ####################################
mkdir -p $ASSETS/thumbs
mkdir -p $ASSETS/videos
if [ $# -gt 1 ]; then
NAME=$1
AUTHOR=$2
INPUT=$3
AULA=$4
OUTPUT=$5
process_video "$NAME" "$AUTHOR" "$INPUT" "$AULA" "$OUTPUT"
exit
fi
# for aula in ./${SRC}/*.md; do
# # ####################################
# # Getting parameters from aulas
# # ####################################
# NAME="$(basename "${aula}" .md)"
# AUTHOR=$(grep "^author: " "${aula}" | sed -e 's/author: //g')
# INPUT="${SRC}/${NAME}.mkv"
#
# process_video "$NAME" "$AUTHOR" "$INPUT"
# done
# rm -f ${TMP}