H.265 files are small, but an MP4 made with libx265 often refuses to play in QuickTime, Safari or on an iPhone, while VLC plays it fine. The reason is a four-letter tag.
ffmpeg -i input.mkv -c:v libx265 -crf 26 -tag:v hvc1 -c:a aac output.mp4
HEVC in MP4 can be tagged in two ways: hev1 or hvc1. ffmpeg uses hev1 by default, and Apple’s players only accept hvc1. -tag:v hvc1 sets the other one. ffprobe shows the tag in codec_tag_string, which is how you can check yours.
If you already have an HEVC file that won’t play on a Mac, you don’t need to encode again. A copy with the tag changed is enough:
ffmpeg -i old.mp4 -c copy -tag:v hvc1 fixed.mp4
I’d keep in mind that the tag only solves the label. Very old Apple devices can’t decode HEVC at all, and 10-bit HEVC is a problem for some older hardware too. If a file needs to play everywhere, H.264 is still the safe choice, at the cost of a bigger file.
Further reading: ffmpeg documentation, FFmpeg wiki: H.265 encoding guide