Your first mistake was buying an apple product.
Sorry I couldn't resist, I know it don't help.
Yep that doesn’t help and it couldn’t be more wrong either
Anyway, you could just connect your iMac to your screen via HDMI. Or depending on what kind of Phone you have you could also just use an adapter and connect that one to your TV.
AirPlay from your Mac would be the easiest option but the current iteration would only support a 1080p video. I don’t know if Airplay 2 supports native 4K. Depending on how old your TV is it may even get native Airplay support via an update in the next weeks.
Different option would be to give your TV access to your macs media library, many TVs have such option. Or at least can access a NAS on the same network.
I wonder why your TV can not play the file format, but if it can’t you can try to convert into another format. If you don’t have any tool you could try to use iMovie, a free video editor available on every Mac