When your cockatiel gets scared at night and it starts flapping its wings, it's not that your cockatiel is having a bad dream, it's rather that your cockatiel just got "startle" or scared by something in the room.
For example moving shadows from a curtain or blinds, car lights, the shadow of you passing by can frighten your cockatiel. These reactions usually happen while you bird is trying to fall asleep.
Placing a bird near a TV or where TV light is perceived is one of the worst things you can do for your bird.
We humans need about 16 to 20 images a second to perceive what we see as continuous film on a TV set, whereas birds need 100 frames per second to see TV images as a moving picture. Having a bird in the same room as a TV with a lower frame rate than that will be very stressful for the creature.
It's cruelty to animals; it's like putting you in a room with strobe lights, like in a disco or club.
If your cockatiel gets scared, it's very important to comfort him and reassure him that everything is OK.
Spend a few minutes petting it until it calms down.
While you pet your cockatiel, check for any injuries it might have suffered from flapping its wings.
Often cockatiels scrape their wings or break a blood feather while flapping their wings. If your cockatiel is bleeding, you will need to stop it quickly, in the case of a blood feather you will need to pull the blood feather out of your cockatiel can bleed to death very quickly. You should always have handy near by the cage needle nose pliers or a hemostat, a towel and Kwik Stop to treat the blood feather injury.
Make sure you cover its cage at night, and move it away from possible moving objects or light sources that might create shadows.
If the material you cover the cage is too light or semi-translucent, your cockatiel might see passing shadows that might startle your bird.
As always the information offered here is to provide guidance and is not intended to be a substitute for the good advice provided by your own avian vet. When in doubt always consult your own veterinarian.