French authorities were investigating Friday how a train was able to smash into a school bus, killing five children and ripping their vehicle in half in an accident that has devastated the local community.

Four teenagers died on Thursday in the collision at a level crossing in the village of Millas near the southern city of Perpignan, and local authorities said a fifth child died of their injuries Friday.

Fifteen other children, all aged between 11 and 17, were injured when the bus was torn in two and the train pulled off its rails in France's worst accident involving a school bus in France for three decades.

The bus driver and three train passengers were also hurt.

"The families of those caught up in the accident are going through something absolutely terrible," said Prime Minister Edouard Philippe, who visited Millas on Thursday.

The accident site was sealed off as police examined whether a technical or human error was to blame.

It has not been confirmed whether the automatic barriers were open at the time of the crash, though national rail operator SNCF said the crossing was "functioning normally", citing witnesses.

Most of the students were from the local Christian Bourquin junior high school, where pupils were in shock as they headed in on Friday.

"I went to sleep at two or three in the morning. I was watching the news, I wasn't able to sleep," said teenager Lorena Garcies, dressed in black.

Her cousin and another friend were on the bus, but escaped with broken bones and trauma.

"I'm trying to be strong for them," she said.

'Total shock'

The injured bus driver, a 48-year-old woman, has not yet been questioned, but Perpignan prosecutor Jean-Jacques Fagni said investigators had spoken to the train driver.

"There was good visibility," said regional chief Carole Delga.

"This level crossing wasn't really dangerous and no technical problems had been raised," she told Europe 1 radio.

She nonetheless pledged to modernise dangerous crossings, as a debate broke out about whether enough has been done to secure some 15,000 similar level crossings in France.

Samuel Conegero, the father of one of the children who survived the accident, said his son took a photo showing "the barriers were lifted" when the bus drove into the path of the incoming train.

"We will obviously consider malfunctions of all kinds," senior police official Jean Valery Letterman told AFP. "This will take time."

At the school, Sabrina Mesas, hugging her daughter Lilou whose best friend was lightly injured in the crash, was struggling to fight back tears.

"We're in total shock," Mesas said. "It's important that everyone is together, that they can talk, to put into words what has happened."

A psychological support team was on site and students were encouraged to come into school -- authorities do not want them to face the tragedy alone, said Abdelkader Taoui, a doctor sent to help.

Teachers have also been left stunned. "I don't even know how to get on with things," said Jordi Sales, who teaches Catalan and Spanish at the school near the Spanish border.

'Vision of horror'

Robert Olive, mayor of neighbouring Saint-Feliu-d'Amont which was home to all of the children who lost their lives, described the accident site as a "vision of horror".

Villagers were walking around in tears.

"The kids were what brought the village alive," said local baker Pierre Alvarez. He has taken down the Christmas decorations at his store.

The accident is the worst involving a school bus in France since 1987, when 53 people including 44 children were killed in a pile-up involving two coaches that were taking students to a summer camp.