Use
ffmpeg -i in.mp4 -vf yadif,format=yuv420p -force_key_frames expr"expr:gte(t\t,n_forced/2)" -c:v libx264 -crf 18 -bf 2 -c:a aac -q:a 1 -ac 2 -ar 48000 -use_editlist 0 -movflags +faststart out.mp4
-vf
specifies video filters
yadif
will deinterlace videos if they're interlaced.
format=yuv420p
will produce pixel format with 4:2:0 chroma subsampling.
-force_key_frames expr"expr:gte(t\t,n_forced/2)"
will place keyframes every half-second, so that will be the GOP size.
-c:v libx264
will use the x264 encoder to produce a H264 video stream.
-crf 18
will produce a visually lossless file. Better than setting a bitrate manually.
-bf 2
will limit consecutive B-frames to 2
-c:a aac
will use the native encoder to produce an AAC audio stream.
-q:a 1
sets the highest quality for the audio. Better than setting a bitrate manually.
-ac 2
rematrixes audio to stereo.
-ar 48000
resamples audio to 48000 Hz.
-use_editlist 0
avoids writing edit lists.
-movflags +faststart
places moov atom/box at front of the output file.