<p>You specify a preset and a quality value at the same time and by that overriding the preset.
I would also recommend you don't encode with ffmpeg while capturing as this would be pretty slow on most PCs.</p>

<p>The "error" in your ffmpeg commandline is the option <code>-crf 1</code>. <code>CRF</code> is a quality setting of x264 and the lower the value the higher the bitrate of the video will be. Setting it to <code>1</code> will make the video pretty much lossless. Just leave that command out and maybe use a preset like <code>medium</code> or <code>slow</code> and not <code>ultrafast</code> like you have right now to get a decent quality.</p>

CC BY-SA 3.0
2014-09-01T18:22:11.373Z
2014-09-02T01:53:27.130Z
2014-09-02T01:53:27.130Z
timonsku
<h1><code>-preset</code></h1>

<p>Use the slowest preset that is fast enough that it does not drop frames. You can see if <code>ffmpeg</code> is dropping frames in the console output (if I recall correctly). Presets are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow.</p>

<h1><code>-crf</code></h1>

<p>Use the highest <code>-crf</code> value that still provides an acceptable quality level. Range is 0-51. 0 is lossless, 18 is generally considered to be visually lossless or nearly so, 23 is default, and 51 is worst quality. Using a value of 1 will likely result in a huge file.</p>

<h3>Also see:</h3>

<ul>
<li><a href="https://trac.ffmpeg.org/wiki/Encode/H.264">FFmpeg H.264 Video Encoding Guide</a></li>
</ul>

CC BY-SA 3.0
2014-09-06T08:28:56.090Z
Thanks a lot for the same input file the initial size was 1.3Go and now only 39Mo.
La Chamelle
CC BY-SA 3.0
2015-02-24T23:45:40.390Z
ultrafast for anything but lossless is a bad idea.  `-preset superfast -x264-params cabac=0` is MUCH better quality per bitrate (RD), and almost as fast.
Peter Cordes
CC BY-SA 3.0
2014-09-02T01:50:30.483Z
2014-09-02T01:50:30.483Z
llogan
<p>I try to create video with <a href="http://code.google.com/p/gource/wiki/Videos" rel="nofollow">gource</a>. I succeed with the following command line:</p>

<pre><code>gource $LOG_FILE --log-format custom --stop-at-end --caption-file ${FILENAME}_captions.log --caption-duration 3 --title $TITLE --seconds-per-day 0.7 --auto-skip-seconds 1 --date-format\
 "%d/%m/%y" --hide "mouse,progress" --user-scale 0.6 --caption-size 20 -1380x950 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420\
p -crf 1 -threads 4 -bf 0 $FILENAME.mp4
</code></pre>

<p>But the video are too big, 9Go for 4 min. How can I reduce the size with ffmpeg?</p>

<p>I use Fedora.</p>

CC BY-SA 3.0
2015-02-24T23:53:50.423Z
Others answers already addressed your `-crf 1`, but `-bf 0` makes little sense.  x264 only uses B frames when they will help overall quality.  If you need compat with ancient hardware players, use `-profile baseline`.  (One case where x264's b-frame decisions aren't optimal (or weren't in 2009?) is a series of not-very-similar still pictures, where lots of I macroblocks are needed: http://forum.doom9.org/showthread.php?t=145005)
Peter Cordes
CC BY-SA 3.0
2015-02-24T23:55:01.040Z
Also, x264 auto-detects how many threads to use.  Only use `-threads` if you want it not to saturate all your CPUs.  (like if `gource` needs significant CPU time?)
Peter Cordes
<ffmpeg>
gource and ffmpeg reduce video size
La Chamelle
# gource and ffmpeg reduce video size

(Asked by: username_0 on 2014-09-01)

I try to create video with gource. I succeed with the following command line:
gource $LOG_FILE --log-format custom --stop-at-end --caption-file ${FILENAME}_captions.log --caption-duration 3 --title $TITLE --seconds-per-day 0.7 --auto-skip-seconds 1 --date-format\
 "%d/%m/%y" --hide "mouse,progress" --user-scale 0.6 --caption-size 20 -1380x950 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420\
p -crf 1 -threads 4 -bf 0 $FILENAME.mp4

But the video are too big, 9Go for 4 min. How can I reduce the size with ffmpeg?
I use Fedora.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Others answers already addressed your `-crf 1`, but `-bf 0` makes little sense.  x264 only uses B frames when they will help overall quality.  If you need compat with ancient hardware players, use `-profile baseline`.  (One case where x264's b-frame decisions aren't optimal (or weren't in 2009?) is a series of not-very-similar still pictures, where lots of I macroblocks are needed: http://forum.doom9.org/showthread.php?t=145005)  
> **username_1**: Also, x264 auto-detects how many threads to use.  Only use `-threads` if you want it not to saturate all your CPUs.  (like if `gource` needs significant CPU time?)  

---

## 2 answers

### Answer by username_3 on 2014-09-02. Score: 7 | Accepted answer

# `-preset`

Use the slowest preset that is fast enough that it does not drop frames. You can see if `ffmpeg` is dropping frames in the console output (if I recall correctly). Presets are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow.

# `-crf`

Use the highest `-crf` value that still provides an acceptable quality level. Range is 0-51. 0 is lossless, 18 is generally considered to be visually lossless or nearly so, 23 is default, and 51 is worst quality. Using a value of 1 will likely result in a huge file.

### Also see:

* [FFmpeg H.264 Video Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/H.264)

> **Comments:**
> **username_0**: Thanks a lot for the same input file the initial size was 1.3Go and now only 39Mo.  
> **username_1**: ultrafast for anything but lossless is a bad idea.  `-preset superfast -x264-params cabac=0` is MUCH better quality per bitrate (RD), and almost as fast.  

---

### Answer by username_2 on 2014-09-01. Score: 4

You specify a preset and a quality value at the same time and by that overriding the preset.
I would also recommend you don't encode with ffmpeg while capturing as this would be pretty slow on most PCs.

The "error" in your ffmpeg commandline is the option `-crf 1`. `CRF` is a quality setting of x264 and the lower the value the higher the bitrate of the video will be. Setting it to `1` will make the video pretty much lossless. Just leave that command out and maybe use a preset like `medium` or `slow` and not `ultrafast` like you have right now to get a decent quality.


---

