Bootanimation/Bootvideo Resolution based on Display

If a 1080p monitor is connected, I want to use a 1080p bootanimation/bootvideo.
If a 4K monitor is connected I want to use a 4K bootanimation/bootvideo.
There will be 2 bootanimations or bootvideos in firmware.

eg. bootanimation.zip and bootanimation_4K.zip
bootanimation.ts and bootanimation_4K.ts

How to make Android choose the correct resolution one based on the attached display?

@mo123 ,
I think you can modify the code implementation here.
frameworks\base\cmds\bootanimation

Read the resolution of the display screen in Uboot or when the kernel driver is loaded, and then make a flag. Bootanimation reads different flag and loads different boot logo files.