From 195e88a079a847bc7402570633d5b3c07ae0ab1e Mon Sep 17 00:00:00 2001 From: www-data Date: Thu, 1 Aug 2024 17:19:19 -0300 Subject: [PATCH] update --- script/script.sh | 101 +++++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 34 deletions(-) diff --git a/script/script.sh b/script/script.sh index 1051d4f..170148f 100755 --- a/script/script.sh +++ b/script/script.sh @@ -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}