Refactor video analysis