Rewrote part of the backend, now using a wrapper for the ffmpeg process

This should make the code less ugly and prone to errors.