Wednesday, October 14, 2015

Blurring Text Minimally in ffmpeg for Smoothing Jaggies

This uses single pass and CRF. This is meant for text based Infographics or Animations.

With mapping and filter_complex:


ffmpeg -i inpu.mov -y -filter_complex "[0:v]boxblur=0.5[o]; [0:a]anull[k]" -map '[o]' -map '[k]' -s 1280x720 -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart out.mp4


With plain video filter and no mapping:


ffmpeg -i input.mov -y -s 1280x720 -vf "smartblur=0.5" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart output.mp4



Note that you can use smartblur or boxblur as per requirements. This has nothing to do with "-vf" or "-filter_complex".

However, smartblur can be more precise and fine tuned. Boxblur seems to have no effect below values of 1 in luma power and radius.

This does not seem to produce results:

ffmpeg -i input.mov -y -s 1280x720 -vf "boxblur=lr=0.8:lp=0.8" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart boxblur_test.mp4


Going up to value of 1 for Luma radius (lr=1) and luma power (lp=1) does have a strong effect- MUCH more than required:

ffmpeg -i input.mov -y -s 1280x720 -vf "boxblur=lr=1:lp=1" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart boxblur_test.mp4


With Smartblur this can be better controlled:

ffmpeg -i input.mov -y -s 1280x720 -vf "smartblur=lr=0.8:ls=0.8" -strict -2 -acodec aac -b:a 128k -vcodec libx264 -pix_fmt yuv420p -threads 4 -crf 8 -refs 8 -bf 0 -coder 0 -g 25 -keyint_min 15 -movflags +faststart Smartblur_test.mp4


Here lr is Luma radius and ls is Luma strength.


No comments:

Post a Comment