Serbia and Croatia have agreed to ease the flow of migrants over the border between the countries after thousands of people, including children, were forced to spend the night in near-freezing temperatures along a muddy border passage.

The interior ministers of Serbia and Croatia said they will start shipping migrants by train directly from Serbia to Croatia so they will not have to cross on foot, with them often trekking for miles.

Migrants will register when they enter Serbia and will be able to cross into Croatia without any delays, which should speed up the process significantly, the ministers said.

"We have agreed to stop this torture," said Croatian interior minister Ranko Ostojic. "There will be no more rain and snow, they will go directly from camp to camp."

Further west, thousands of migrants aiming to reach northern Europe walked out of refugee camps on the border between Slovenia and Austria on their own, frustrated after waiting long hours in overcrowded facilities.

Eager to move on, thousands spread around along railway tracks, highways and mountain roads. Confused and unaware which roads to take to go west, some migrants later turned back and returned to the refugee camps to wait for bus transport to other locations.

Tensions have been building after the so-called Balkan route shifted. Migrants still cross first from Greece into Macedonia and then Serbia, but now go via Croatia and Slovenia instead of Hungary, which has erected fences along its borders with Serbia and Croatia.

Overwhelmed after nearly 50,000 migrants crossed in just a few days, Slovenia said it has not ruled out erecting a fence of its own along parts of its 400-mile border with Croatia.

Prime Minister Miro Cerar said Slovenia will consider all options if left to cope on its own with the influx of thousands of people.

"Our sights are foremost on finding a European solution," said Mr Cerar. "But should we lose hope for this ... all options are open within what is acceptable."

The country of two million people has already deployed 650 troops to help the police manage the flow and has asked the European Commission for an aid package, including £43 million in financial aid and police gear and personnel.

Several EU nations have promised to send police officers to help Slovenia's force, which is so overloaded that a football derby on Saturday had to be cancelled because there were no more officers available to guard the game.

Slovenia and Croatia have accused each other of mishandling the crisis. Slovenia initially said it could take in only 2,500 people a day and accused Croatia of dropping migrants uncontrollably at its doorstep.

At the Serbian border, some 5,000 people gathered around fires, under tents and wrapped in blankets as they waited all night to cross into Croatia. Ministers said registration of refugees must speed up so that there are no delays in the transfer of migrants toward Western Europe.

Serbian minister Nebojsa Stefanovic said the two countries will ask the EU to recognise the Serbian registration process - which includes finger and palm-printing and biometric passes - so that migrants do not have to undergo the same procedure over and over again.

"With the winter coming, it is important to agree on a speedy flow of these people," Mr Stefanovic said.

EU officials have called a summit for Sunday of several EU and Balkan leaders to focus on the migrant crisis.