HELICOPTER footage has been played in court showing the moment a shotgun was apparently fired at two police officers in an alleged attempt to murder them.

Daniel Hannam, 32, is said to have unlawfully obtained the double-barrelled weapon and a large number of cartridges.

Bristol Crown Court has heard that he fired it into the air three times in the centre of Castle Cary.

Armed police later surrounded his former girlfriend's home after 999 calls from the public.

Footage from body-worn cameras and the police helicopter shows two officers, referred to as IC and IX, making their way towards the front door.

IC and IX approached the house and shouted "armed police", and kicked the door, but there was no reply.

They returned a second time and heard a colleague shout there was "twitching" at an upstairs window.

The footage appears to show at least one shot being fired from the window, with both officers below returning fire.

"From my perspective of seeing that firearm coming out, I would suggest that the only reason that we weren't hit was because of the lack of accuracy," IC told the jury.

"We attended that address. There was no sign of life at all until the point that firearm was aimed at us.

"It was quite apparent that we were there. The fact that it didn't hit me is luck and that's why I'm here today.

"The image of that firearm doing what it did is ingrained in me."

READ MORE: Court shown images of moment police officers claim they were fired at

The court heard that a shotgun blast went about two metres over the officers' heads, with pellets hitting the side of an armed response vehicle parked near the house.

Another firearms officer, identified as PJ, told the court he was going back towards the car when "all hell broke loose".

"There was lots of shouting, challenges and gunshots," PJ told the jury.

"I felt things hit me - my helmet, bits hitting the back of my body armour. It was like being in a sandstorm.

"My initial reaction was that I had been shot."

Somerset County Gazette:

Another firearms officer identified as AC described hearing "two loud bangs" and PJ shouting "contact".

"After that, there was a number of shots that I heard," AC said. "They were different. The sound was more of a crack rather than a boom."

The court has heard that Hannam insists he only fired one shot, which was aimed into the air and not at officers.

He had gone to the home of his on-off girlfriend in Park Street on the evening of January 22.

In the early hours of January 23, he took his shotgun and cartridges into town to meet a man.

He later told police he fired the gun into the air while waiting for the man, then returned to Park Street.

He left the property to buy cocaine but could not reach his supplier.

Hannam shot at the door of a newsagents before walking to a car park at 1.44am, where he approached a BMW.

He is accused of attempting to kidnap the driver, Oliver Walter-Taylor, by getting into the car and pointing the shotgun at him.

After a struggle, both men got out and Hannam allegedly fired two shots in the air, with pellets hitting the car.

Police attended Park Street at 2.10am, surrounding the end-of-terrace home by 2.45am.

At 4.25am, Hannam threw the shotgun out of the back window of the house and was arrested.

He denies two counts of attempting to murder a police officer, possessing a firearm with intent to endanger life and attempting to kidnap Mr Walter-Taylor.

The trial continues.

Somerset County Gazette: