Made some adjustments to the ffmpeg options + some corrections in the code.