MP4 is a container format. Depending on your ffmpeg configuration ffmpeg will either use the encoder mpeg4 for MPEG-4 Part 2 video or libx264 for H.264 video.
mpeg4
Rate control methods include -qscale:v and -b:v. These are mutually exclusive so you should use one or the other.
-qscale:v
Sets a constant quantizer, but general users can just think "constant quality". Effective range is 2-31 where 2 is highest quality.
ffmpeg -i input -codec:v mpeg4 -codec:a libmp3lame -qscale:v 4 -qscale:a 5 out.mp4
-b:v
Allows a video bitrate to be applied. Can be used to target a specific output file size (filesize = duration x bitrate).
ffmpeg -i input -codec:v mpeg4 -codec:a libmp3lame -b:v 512k -b:a 128k out.mp4
Also see:
libx264
Rate control methods include -crf, -b:v, and -qp, but for the vast majority of users -qp can be ignored.
-crf
Constant Rate Factor. Think of it as a "smart" version of -qscale:v. Range is logarithmic 0-51. 0 is lossless (big files), ~18 is roughly visually lossless, 23 is default, and 51 is worst quality.
ffmpeg -i input -codec:v libx264 -crf 23 -preset medium -codec:a libfdk_aac -vbr 5 output.mp4
-b:v
Allows a video bitrate to be applied. Can be used to target a specific output file size (filesize = duration x bitrate). Two-pass example:
ffmpeg -y -i input -pass 1 -codec:v libx264 -preset medium -b:v 800k -an -f mp4 /dev/null
ffmpeg -y -i input -pass 2 -codec:v libx264 -preset medium -b:v 800k -codec:a libfdk_aac -b:a 128k output.mp4
Also see: