added videowriter function and end result save