copy pasted into CloseFfmpeg