Install ffmpeg
brew install ffmpeg
Note that lower CRF values correspond to higher bitrates, and hence produce higher quality videos.
ffmpeg -i input.mp4 -c:v libx265 -preset fast -crf 28 output.mp4
Needed on macOS: to preserve compatibility encoding H.265/HEVC for QuickTime
ffmpeg -i input.mp4 -c:v libx265 -preset fast -crf 28 -tag:v hvc1 -c:a eac3 -b:a 224k output.mp4