Propperly lock ffmpeg