Script para compilação

De Física Computacional
Revisão de 12h32min de 1 de maio de 2022 por Samuelhd (discussão | contribs)
Ir para navegação Ir para pesquisar

Script para automatizar a criação dos vídeos. É necessário que os arquivos de código e script estejam nos diretórios indicados no primeiro link dessa página sobre a FPUT para descolamento vertical.

#!/bin/bash

# Run all the scripts
# Compile the C code -> Run the executable -> Run the gnuplot script -> Create the video file from the images on the img folder

# Variable to save the current time
name=$(date +%s)

# Compile the C code
gcc fput.c -lm
# Run the executable 
./a.out
# Create the folder to save the images
mkdir -p ../img/$name
# Run gnuplot script and save the results in img/$name
gnuplot -e "dir='$name'" graph.plt
# Create the video folder if it doesn't exist
mkdir -p ../video
# Create the MP4 video
ffmpeg -r 120 -i ../img/$name/fput%d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p ../video/output-$name.mp4

# In onder to create the gif
# ffmpeg -y -i ../video/output-$name.mp4 -vf palettegen ../video/palette.png
# ffmpeg -y -ss 0 -t 20 -i ../img/$name/fput%d.png -i ../video/palette.png -filter_complex paletteuse -r 20 ../video/output-$name-part1.gif
# ffmpeg -y -ss 190 -t 20 -i ../img/$name/fput%d.png -i ../video/palette.png -filter_complex paletteuse -r 20 ../video/output-$name-part2.gif