I made a .webm by compiling a series of rendered out images with FFMPEG. I'm intending for it to loop in background. The problem is, the first frame/frames (not sure) come out very blocky. I used this:

ffmpeg -f image2 -i img%05d.png -vf fps output3.webm

anything I am missing to avoid this issue?


Try something like this:

ffmpeg -f image2 -framerate 30 -i img%05d.png -c:v libvpx-vp9 -b:v 0 -pix_fmt yuv420p -crf 30 -cpu-used 1 -tile-columns 2 -threads 8 -row-mt 1 output.webm

  • Placing -framerate 30 before the input specifies it as the frame rate of the input to be 30. This is then inherited as the output frame rate as well.

  • -c:v libvpx-vp9 specifies that you want to use VP9. If you want to use VP8, use -c:v libvpx instead. VP8 has lower compression efficiency but is also less demanding to decode.

  • -b:v 0 is required for -crf to work the way most people expect when using libvpx or libvpx-vp9. This is very important when it comes to quality, if you forget this your video is going to look bad at a CRF that would normally look good.

  • -pix_fmt yuv420p set the colorspace to 4:2:0 which is important for wide player compatibility and hardware acceleration. This is essential when converting a series of images into a video since forgetting to set this leads to higher file sizes due to increased color representation capability and can make some players display the video incorrectly or to not play it at all.

  • -crf 30 sets the bitrate control mode to Constant Quality and the value to 30. In my experience this is a good value to start with. Lower values lead to higher quality. Try out different values to find out what works best for your content.

  • -cpu-used 1 sets the encoding speed, lower values equal better compression. 0 is the lowest speed and highest compression efficiency while 5 is the fastest speed and lowest compression efficiency.

  • -tile-columns 2 specifies that the video will use two tile columns. These are used to achieve multi-threaded encoding and depending on how old your version of FFmpeg is this might not be set automatically. 2 columns is suitable for 720p and 1080p video. Refer to Google's VP9 encoding guide for the suitable amount of tile columns and the amount of threads they allow you to use.

  • -threads 8 defines the amount of processing threads available for encoding. Set this to the amount of cores (or threads if you have HyperThreading/SMT available) on your CPU for the fastest encoding. This option still needs to be set manually even in latest versions of FFmpeg or else libvpx will only use one thread, which slows down encoding significantly.

  • -row-mt 1 enables better multithreading for libvpx. Setting this manually doesn't seem to be necessary in recent versions of FFmpeg but it doesn't hurt either.

| improve this answer | |

You don’t declare a codec or quality. Try this:

ffmpeg -f image2 -i img%05d.png -c:v libvpx -crf 10 -vf fps output3.webm

Reducing the 10 after crf should increase the quality. Also, “-vf fps”, I think defaults to 25 FPS. If you want something different, say 30 FPS, you would write it:

-vf fps=“fps=30”
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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