2
I use the code below to generate new videos (from the respective folder) by inserting the name and CPF of the student in each video.
However, this way, the compilation takes a long time, since the compilation time is the time of the video. I need something faster, I want to insert the text only from the 5th to the 10th second of the video and then stop.
As if dividing the video, insert the text. No need to compile the whole video. I believe it is necessary, before, to make a copy of the videos and then a code that just inserts the text in time.
The script I use is:
#!/bin/bash
echo "Nome do aluno"
read nome;
echo "CPF do aluno"
read cpf;
mkdir $cpf;
echo “iniciando a compilação para o aluno $nome”
[ "$1" ] && cd "$1"
ls -1 *.mp4
[ "$?" -ne 0 ] && echo 'Sem arquivos mp4 nesse diretório' && exit 0
for ARQUIVO in $(ls -1 *.mp4)
do
ARQ_DESTINO="${ARQUIVO%%.mp4}.mp4"
echo "Convertendo $ARQUIVO para $ARQ_DESTINO"
ffmpeg -i "$ARQUIVO" -strict experimental -vf "drawtext=fontfile='/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf':text='Liberado para $nome - $cpf':x=200:y=10:fontsize=16:enable='between(t,5,10)'" /var/www/Arquivos/videos/$cpf/"$ARQ_DESTINO"
done
As I will sell videos online, I have set up a server to create these videos. However, each class package is around 6 hours long. If 4 people buy per day my server will work all day to mount these new videos. So it becomes unviable, there is a faster solution?
I can’t test it, but I believe the solution is split and Concat: Join mp4 files in linux. A file with the first 5 seconds, another with the custom 5 seconds created on-the-fly and another with the rest.
– brasofilo