1

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.

2
  • 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: forum.doom9.org/showthread.php?t=145005) Feb 24, 2015 at 23:53
  • 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?) Feb 24, 2015 at 23:55

2 Answers 2

6

-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:

2
  • Thanks a lot for the same input file the initial size was 1.3Go and now only 39Mo. Sep 6, 2014 at 8:28
  • 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. Feb 24, 2015 at 23:45
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.