saveImg from Video function and a bit of refactoring