An armed attacker who tried to murder two teenagers in assaults caught on camera has been jailed for five-and-a-half years.