I have enabled stats for nerds option in YouTube android app and played the same video in "Vivo V9" and "Nexus 5" device.
Vivo V9 : It played the video in WebM format which is basically "VP8 or VP9" codec.
Nexus 5 : It played the video in MP4 format which is basically "H264 or H265" codec.
So, based on the device YouTube app selects video codec.
Question : How does it do ? I know internally it uses ExoPlayer for playing video but ExoPlayer by default doesn't give functionality.