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
SRC=collections/_aulas
SCRIPT=script/
TMP=tmp/
# SCRIPT=script/
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"
mkdir -p ./${TMP}
process_video () {
NAME=$1
AUTHOR=$2
INPUT=$3
AULA=$4
OUTPUT=$5
# ####################################
# 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
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"
# no output path
if [ -z "$OUTPUT" ]; then
OUTPUT="$ASSETS/videos/${NAME}.mp4"
fi
echo "########################################"
echo "# Aula: ${aula}"
echo "# Aula: ${AULA}"
echo "# Author: ${AUTHOR}"
echo "# Input: ${INPUT}"
echo "# Src: ${SRC}"
echo "# Dest: ${OUTPUT}"
echo "# Name: ${NAME}"
echo "# Script Path: ${SCRIPT}"
echo "########################################"
# exit
# ####################################
# Creating the thumbnail if does not exist
# ####################################
if test ! -f "./assets/thumbs/${NAME}.jpg" ; then
ffmpeg -y -i "${INPUT}" -vframes 1 -an -s 400x222 -ss 30 "./assets/thumbs/${NAME}.jpg"
if test ! -f "$ASSETS/thumbs/${NAME}.jpg" ; then
ffmpeg -y -i "${INPUT}" -vframes 1 -an -s 400x222 -ss 30 "$ASSETS/thumbs/${NAME}.jpg"
fi
# ####################################
# if output exist, continue
# ####################################
if test -f "./assets/videos/${NAME}.mp4" ; then
if test -f "$ASSETS/videos/${NAME}.mp4" ; then
continue
fi
# ####################################
# 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
# ###################################################
@ -94,7 +86,48 @@ for aula in ./${SRC}/*.md; do
-vcodec libx264 \
-pix_fmt yuv420p \
-vsync 2 \
"./assets/videos/${NAME}.mp4"
done
"$OUTPUT"
}
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}