H.264 is a very good and popular video compression format. H.265 is the successor which achieves a much better compression rate while maintaining the same quality level. After installing ffmpeg and libx265, this is the way to use it:
ffmpeg -i inputfile.mp4 -vcodec libx265 -crf 28 -acodec aac -b:a 128k outputfile.mp4
This example uses a quality level (using crf) instead of specifying a video bitrate (using -b:v 2000k for example). The default is 28. Higher means higher compression and lower quality. The -b:a is for the audio bitrate.