Poor baby! I feel so sorry for him when he bangs his head.
This reminds me of
REM Sleep Behavior Disorder in humans, which can be a sign of impending Parkinson's disease.
It also looks like he might be having epileptic seizures.
I hope his owner has taken him to a vet and is taking good care of him. If it were my dog, I would be very worried.