FFMpeg - why recording a video and then compressing it produces a smaller size video than recording with combined options I played a recorded video to test this, so video content would be same in both cases. 

Recorded video length is 1 Minute in both cases.

There may be a split second difference in the videos as I start FFMpeg command in cmd window and then switch to VLC player to playback video.

1) command to record:

ffmpeg -f gdigrab -framerate 30 -i desktop -f segment -segment_time 60 out12Dec1%03d.flv


This recorded video of 1 min is 9.99 MB.

2) command to compress:

ffmpeg -i out12Dec1000.flv -vcodec libx264 -crf 20 output.mp4


This compresses the video to 1.76 MB

3) Now I am trying to use the parameters to directly capture in compressed mode instead of using 2 steps.

ffmpeg -f gdigrab -framerate 30 -i desktop -f segment -segment_time 60 -vcodec libx264 -crf 20  outvcodec12Dec19%03d.mp4


I tried both with and without framerate option, and used flv / mp4 for output.
The output videos are between 2.24 to 2.57 MB.

Why is the recorded output in case 3 not close to 1.76 MB?
Your first command is transcoding using FLV1 codec to store in .flv. This is not the same input provided to the x264 encoder as when directly encoded to H264. In fact, it's quite worse, since the default target bitrate set for FLV1 is 200 kbps (although for full desktop capture, it will overshoot by a lot). This has less complex detail in general so it's easier for x264 to encode than the full fidelity raw desktop input.