Search This Blog

Saturday, May 7, 2011

Using sharpening filter with mencoder (h264 codec). Easy tutorial

To use this method you’ll need mencoder.exe which is part of the mplayer distribution. Download it here.
There is the “-vf” switch that stands for “video filter”. The unsharp filter is used both for blurring and sharpening. Negative values are blurr, positive sharpening. Remember to put the –vf switch in the beginning of the command.

the parameter is:
-vf unsharp=7:7:2.5:7:7:2.5
for both luma & chroma sharpening.

Values stand for:
luma_msize_x:luma_msize_y:luma_amount:chroma_msize_x:chroma_msize_y:chroma_amount

EXAMPLE:
mencoder INPUT_FILE -vf unsharp=7:7:2.5:7:7:2.5 -ofps 30000/1001 -ovc x264 -x264encopts subq=1:frameref=1:pass=1:threads=2 -nosound –o OUTPUT_FILE.x264.avi

HELP:
Negative values for the amount will blur the input video, while positive values will sharpen. All parameters are optional and default to the equivalent of the string '5:5:1.0:0:0:0.0'.
`luma_msize_x'

Set the luma matrix horizontal size. It can be an integer between 3 and 13, default value is 5.
`luma_msize_y'
Set the luma matrix vertical size. It can be an integer between 3 and 13, default value is 5.
`luma_amount'
Set the luma effect strength. It can be a float number between -2.0 and 5.0, default value is 1.0.
`chroma_msize_x'
Set the chroma matrix horizontal size. It can be an integer between 3 and 13, default value is 0.
`chroma_msize_y'
Set the chroma matrix vertical size. It can be an integer between 3 and 13, default value is 0.
`luma_amount'
Set the chroma effect strength. It can be a float number between -2.0 and 5.0, default value is 0.0.

# Strong luma sharpen effect parameters
unsharp=7:7:2.5

# Strong blur of both luma and chroma parameters
unsharp=7:7:-2:7:7:-2

5 comments:

  1. or if you are using a resizing filter then -ssf (simple sharpening) can work.

    ReplyDelete
  2. The suggested format "unsharp=7:7:-2:7:7:-2 " does not work, while the format used made referenced from the manual "unsharp=l7x7:-2:c7x7:-2" works. This may due to different version of mencoder being used. If you can't work you may try this command format.

    ReplyDelete

If you like this post, please leave a comment :)