2024-05-23 01:23:48 -03:00
|
|
|
#!/bin/sh
|
2024-07-10 14:19:15 -03:00
|
|
|
SRC=_aulas
|
|
|
|
SCRIPT=script/
|
|
|
|
TMP=tmp/
|
|
|
|
PARAM="scale=1920:1080: force_original_aspect_ratio=decrease: eval=frame,pad=1920:1080: -1:-1:color=black"
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p ./${TMP}
|
2024-05-23 01:23:48 -03:00
|
|
|
|
|
|
|
# ####################################
|
|
|
|
# Creating the credits clip
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
if test ${SCRIPT}/tmp-credits.mkv -ot ${SCRIPT}/credits.svg ; then
|
|
|
|
ffmpeg -y -loop 1 -i ${SCRIPT}/credits.svg -i ${SCRIPT}/credits.wav -shortest ${TMP}/tmp-credits.mkv
|
2024-05-23 01:23:48 -03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ####################################
|
|
|
|
# Creating dest dir
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
mkdir -p ./thumbs
|
|
|
|
mkdir -p ./videos
|
2024-05-23 01:23:48 -03:00
|
|
|
|
2024-07-10 14:19:15 -03:00
|
|
|
for aula in ./${SRC}/*.md; do
|
2024-05-23 01:23:48 -03:00
|
|
|
# ####################################
|
|
|
|
# Getting parameters from aulas
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
NAME="$(basename "${aula}" .md)"
|
2024-05-23 01:23:48 -03:00
|
|
|
AUTHOR=$(grep "^author: " "${aula}" | sed -e 's/author: //g')
|
2024-07-10 14:19:15 -03:00
|
|
|
INPUT="${SRC}/${NAME}.mkv"
|
2024-05-23 01:23:48 -03:00
|
|
|
|
|
|
|
echo "########################################"
|
|
|
|
echo "# Aula: ${aula}"
|
|
|
|
echo "# Author: ${AUTHOR}"
|
|
|
|
echo "# Input: ${INPUT}"
|
|
|
|
echo "# Src: ${SRC}"
|
|
|
|
echo "# Name: ${NAME}"
|
|
|
|
echo "# Script Path: ${SCRIPT}"
|
|
|
|
echo "########################################"
|
|
|
|
|
|
|
|
# ####################################
|
|
|
|
# Creating the thumbnail if does not exist
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
if test ! -f "./thumbs/${NAME}.jpg" ; then
|
|
|
|
ffmpeg -y -i "${INPUT}" -vframes 1 -an -s 400x222 -ss 30 "./thumbs/${NAME}.jpg"
|
2024-05-23 01:23:48 -03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ####################################
|
|
|
|
# if output exist, continue
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
if test -f "./videos/${NAME}.mp4" ; then
|
2024-05-23 01:23:48 -03:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ####################################
|
|
|
|
# Creating the intro clip
|
|
|
|
# ####################################
|
2024-07-10 14:19:15 -03:00
|
|
|
sed "s/nomenome/$AUTHOR/g" ${SCRIPT}/intro.svg | sed "s/curso/${NAME}/g" > ${TMP}/tmp-intro.svg
|
|
|
|
ffmpeg -y -loop 1 -i ${TMP}/tmp-intro.svg -i ${SCRIPT}/intro.wav -shortest ${TMP}/tmp-intro.mkv
|
2024-05-23 01:23:48 -03:00
|
|
|
|
|
|
|
# ###################################################
|
|
|
|
# Audio adjustment
|
|
|
|
# ###################################################
|
|
|
|
# Some possible options
|
|
|
|
# -af loudnorm
|
|
|
|
# -af dynaudnorm=p=1
|
|
|
|
# -af speechnorm=e=12.5:r=0.0001:l=1
|
|
|
|
# -af acompressor=threshold=0.089:ratio=9:attack=200:release=1000:makeup=2
|
2024-07-10 14:19:15 -03:00
|
|
|
ffmpeg -y -i "${INPUT}" -af dynaudnorm=p=1 ${TMP}/tmp-normalized.mkv
|
2024-05-23 01:23:48 -03:00
|
|
|
|
|
|
|
# ####################################################
|
|
|
|
# Wartermarking the video file
|
|
|
|
# ####################################################
|
2024-07-10 14:19:15 -03:00
|
|
|
sed "s/nomenome/$AUTHOR/g" ${SCRIPT}/watermark.svg | sed "s/curso/${NAME}/g" > ${TMP}/tmp-watermark.svg
|
2024-05-23 01:23:48 -03:00
|
|
|
# add watermark to video
|
2024-07-10 14:19:15 -03:00
|
|
|
ffmpeg -y -i ${TMP}/tmp-normalized.mkv -i ${TMP}/tmp-watermark.svg -i ${SCRIPT}/logo.png \
|
|
|
|
-filter_complex "[0][1]overlay=5:H-h-5:format=auto[bg];[bg][2]overlay=W-w-5:5:format=auto" -c:a copy ${TMP}/tmp-video.mkv
|
2024-05-23 01:23:48 -03:00
|
|
|
|
|
|
|
# ####################################################
|
|
|
|
# Concatenating videos
|
|
|
|
# ####################################################
|
|
|
|
|
|
|
|
ffmpeg -y \
|
2024-07-10 14:19:15 -03:00
|
|
|
-i ${TMP}/tmp-intro.mkv \
|
|
|
|
-i ${TMP}/tmp-video.mkv \
|
|
|
|
-i ${TMP}/tmp-credits.mkv \
|
2024-05-23 01:23:48 -03:00
|
|
|
-filter_complex \
|
|
|
|
"[0:v]$PARAM[v0]; [1:v]$PARAM[v1]; [2:v]$PARAM[v2]; [v0][0:a][v1][1:a][v2][2:a] concat=n=3:v=1:a=1 [v] [a]" \
|
|
|
|
-map [v] -map [a] \
|
|
|
|
-s hd720 \
|
|
|
|
-vcodec libx264 \
|
|
|
|
-pix_fmt yuv420p \
|
|
|
|
-vsync 2 \
|
2024-07-10 14:19:15 -03:00
|
|
|
"./videos/${NAME}.mp4"
|
2024-05-23 01:23:48 -03:00
|
|
|
done
|
|
|
|
|
2024-07-10 14:19:15 -03:00
|
|
|
rm -f ${tmp}
|