This is the two-pass command, using a 2048k video bitrate:

ffmpeg -y -i <input>.mp4 -c:v libx264 -preset medium -b:v 2048k -pass 1 -c:a libfdk_aac -b:a 128k -f mp4 /dev/null && ffmpeg -i <input>.mp4 -c:v libx264 -preset medium -b:v 2048k -pass 2 -c:a libfdk_aac -b:a 128k <output>.mp4