Here's the structure:
Had + been + verb-ing
For example:
* I had been working for three hours before I took a break.
* They had been playing in the park all afternoon.
The perfect progressive tense emphasizes that an action started in the past, continued for a period of time, and was completed before another action or point in time.