#!/bin/bash

# Zsolt Keszthelyi, 2022

# script to make videos from png files that mesa outputs. 
# this script assumes it is in the work directory and that in this work directory there is a directory called 'png'
# which contains different directories with pngs in them. 

cd png
for d in */ ; do
    cd $d
    ffmpeg -framerate 10 -i %*.png -c:v libx264 -r 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p out.mp4
    name="${d::-1}".mp4
    mv out.mp4 $name
    cp $name /media/sf_mesashared/  #copy videos here
    cd ..
done
