Difference with past continuous:
Past continuous emphasizes interrupted actions, whereas past perfect continuous emphasizes a duration of time before something in the past.
I was reading when she walked in. / I had been reading for three hours when she walked in.