Answers.Body: <p>Your first command is transcoding using FLV1 codec to store in <code>.flv</code>. 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-13T00:33:21.320Z
Answers.Text: You might want to expand a bit on what you mean by "worse". I take it that you're saying that the material is already compressed, so there is less detail, which makes it easier to recompress into a smaller file.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-13T05:00:30.317Z
Answers.Text: Indeed. Added..
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-13T05:20:48.423Z
Answers.Text: Thanks. Can we conclude that recording a video and then compressing will always create a smaller file size, or can I use some other options while recording?
Answers.UserDisplayName: Deepak Garud
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-13T06:22:27.507Z
Answers.Text: With your current commands, yes, but the quality will be worse. I would recommend encoding to H264 directly, with these settings: `ffmpeg -f gdigrab -framerate 30 -i desktop -pix_fmt yuv420p -c:v libx264 -crf 20 -preset veryfast -f segment -segment_time 60 out12Dec1%03d.flv`.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-12T17:16:16.143Z
Answers.LastActivityDate: 2018-12-13T05:00:19.747Z
Answers.LastEditDate: 2018-12-13T05:00:19.747Z
Answers.UserDisplayName: Gyan
Body: <p>I played a recorded video to test this, so video content would be same in both cases. </p>
  
  <p>Recorded video length is 1 Minute in both cases.</p>
  
  <p>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.</p>
  
  <p>1) command to record:</p>
  
  <pre><code>ffmpeg -f gdigrab -framerate 30 -i desktop -f segment -segment_time 60 out12Dec1%03d.flv
  </code></pre>
  
  <p>This recorded video of 1 min is 9.99 MB.</p>
  
  <p>2) command to compress:</p>
  
  <pre><code>ffmpeg -i out12Dec1000.flv -vcodec libx264 -crf 20 output.mp4
  </code></pre>
  
  <p>This compresses the video to 1.76 MB</p>
  
  <p>3) Now I am trying to use the parameters to directly capture in compressed mode instead of using 2 steps.</p>
  
  <pre><code>ffmpeg -f gdigrab -framerate 30 -i desktop -f segment -segment_time 60 -vcodec libx264 -crf 20  outvcodec12Dec19%03d.mp4
  </code></pre>
  
  <p>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.</p>
  
  <p>Why is the recorded output in case 3 not close to 1.76 MB? </p>
  
Tags: <ffmpeg>
Title: FFMpeg - why recording a video and then compressing it produces a smaller size video than recording with combined options
UserDisplayName: Deepak Garud
ThreadText: # FFMpeg - why recording a video and then compressing it produces a smaller size video than recording with combined options
  
  (Asked by: username_0 on 2018-12-12)
  
  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?
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-12. Score: 0 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_2**: You might want to expand a bit on what you mean by "worse". I take it that you're saying that the material is already compressed, so there is less detail, which makes it easier to recompress into a smaller file.  
  > **username_1**: Indeed. Added..  
  > **username_0**: Thanks. Can we conclude that recording a video and then compressing will always create a smaller file size, or can I use some other options while recording?  
  > **username_1**: With your current commands, yes, but the quality will be worse. I would recommend encoding to H264 directly, with these settings: `ffmpeg -f gdigrab -framerate 30 -i desktop -pix_fmt yuv420p -c:v libx264 -crf 20 -preset veryfast -f segment -segment_time 60 out12Dec1%03d.flv`.  
  
  ---
  
  