FFmpeg command for Blur, Sharpen and Other Denoising

FFmpeg, a powerful multimedia processing tool, provides a suite of filters to enhance video quality, including options for blurring, sharpening, and denoising. These filters allow content creators and video editors to improve visual aesthetics and reduce noise in their videos. In this comprehensive guide, we will explore the FFmpeg commands for applying blur, sharpening, and denoising effects, providing detailed instructions and customization options.

  1. Installing FFmpeg:
    Before proceeding, ensure FFmpeg is installed on your system. Download the latest version from the official website (https://ffmpeg.org/download.html) or use package managers like Homebrew on macOS or APT on Linux.
  2. Navigate to the Video File Directory:
    Open a terminal or command prompt and navigate to the directory containing the video file you want to enhance. Use the cd command to change the directory:
   cd /path/to/video/directory
  1. Execute FFmpeg Command – Applying Blur:
    To apply a blur effect to a video, use the following FFmpeg command:
   ffmpeg -i input_video.mp4 -vf "boxblur=5" -c:a copy output_blurred_video.mp4

Breakdown of the command:

  • -i input_video.mp4: Specifies the input video file.
  • -vf "boxblur=5": Applies a box blur filter with a radius of 5 pixels.
  • -c:a copy: Copies the audio stream without re-encoding.
  • output_blurred_video.mp4: Defines the output filename for the blurred video.
  1. Execute FFmpeg Command – Applying Sharpening:
    To apply a sharpening effect to a video, use the following FFmpeg command:
   ffmpeg -i input_video.mp4 -vf "unsharp=5:5:1.0:5:5:0.0" -c:a copy output_sharpened_video.mp4

Breakdown of the command:

  • -i input_video.mp4: Specifies the input video file.
  • -vf "unsharp=5:5:1.0:5:5:0.0": Applies an unsharp mask filter with specific parameters.
    • 5:5:1.0 defines the filter strength, radius, and threshold.
  • -c:a copy: Copies the audio stream without re-encoding.
  • output_sharpened_video.mp4: Defines the output filename for the sharpened video.
  1. Execute FFmpeg Command – Denoising with Temporal Noise Reduction (TNR):
    To apply temporal denoising to a video, use the following FFmpeg command:
   ffmpeg -i input_video.mp4 -vf "hqdn3d=4:3:6:4" -c:a copy output_denoised_video.mp4

Breakdown of the command:

  • -i input_video.mp4: Specifies the input video file.
  • -vf "hqdn3d=4:3:6:4": Applies a high-quality 3D spatial and temporal noise reduction filter with specific parameters.
    • 4:3:6:4 defines the luma spatial, chroma spatial, luma temporal, and chroma temporal thresholds.
  • -c:a copy: Copies the audio stream without re-encoding.
  • output_denoised_video.mp4: Defines the output filename for the denoised video.
  1. Adjusting Parameters:
  • Blur Radius (boxblur=): Modify the radius to control the strength of the blur effect.
  • Sharpening Parameters (unsharp=): Adjust the strength, radius, and threshold for the sharpening effect.
  • Temporal Noise Reduction Parameters (hqdn3d=): Modify the spatial and temporal thresholds for denoising.
  1. Executing the Commands:
    Press Enter to execute the FFmpeg commands. FFmpeg will process the videos, applying the specified blur, sharpening, or denoising effects. The progress will be displayed in the terminal.
  2. Viewing the Output:
    Once the process is complete, navigate to the output directory where the enhanced videos are saved. Open the generated files using a media player to inspect the applied effects.
  3. Customization and Additional Options:
    Explore FFmpeg’s extensive documentation for advanced options, such as combining multiple filters, adjusting filter strengths, or using other denoising filters. Customizing the commands allows you to tailor the video enhancements to your specific requirements.

FFmpeg Blur video effect

A blur effect is used to increase the quality of certain type of noise in images (video frames), where each output pixel value is calculated from the neighboring pixel values. For instance, the blur effect can improve images scanned from a printed half-tone pictures. To blur an input video we can use a boxblur filter

For example to create a blur effect on the input video where luma radius value is 1.5 and luma power value is 1, we can use the next command:

ffmpeg -i input.mpg -vf boxblur=1.5:1 output.mp4

FFmpeg Sharpen video

The sharpen filter can be used as a common unsharp mask and a Gaussian blur. For example to sharpen the input with default values we can use the command

ffmpeg -i input -vf unsharp output.mp4

The output will be sharpen with a luma matrix of the size 5×5 and the luma effect strength of 1.0. To create a Gaussian blur effect, we can use a negative number for the luma and/or chroma value, for example

ffmpeg -i input -vf unsharp=6:6:-2 output.mp4

Noise reduction with denoise3d

For example to enhance the input with the default values of the denoise3d filter we can use the command

ffmpeg -i input.mpg -vf mp=denoise3d output.webm

Conclusion:
Enhancing video quality with FFmpeg provides a versatile and efficient solution for content creators and video editors. By following this comprehensive guide, you can use FFmpeg to apply blur, sharpening, and denoising effects, bringing visual improvements to your videos.

Leave a Comment