The concept is the same as present perfect continuous. The action happens before a time in the past.
When I arrived at the bus stop, the other people had been waiting for twenty minutes.
Did the action continue or not? Depends on context.
When I left the house, they had been playing for five hours. Who knows when they stopped.
When I started at the shop, my boss had been working there for five years.