FFmpeg delivers a lot of video filters including a filter called “delogo”. This one can be used to remove a station logo from a video.
How it works
First we need to define a square that contains the logo. Then the filter uses surrounding pixels outside of the square to calculate new pixels that are replacing the logo.
Step by Step
FFmpeg is easy to use: Just define with the parameter -i an input file (the original video file). Place at the end the output file name:
./ffmpeg -i InputVideo.mp4 OutputVideo.mp4
Let’s have a look at the filter. For this filter 4 parameters are required:
- x and y define the position of the square with the logo
- w and h define the width and height of the square containing the logo
The parameters are separated by a “:”. As an example: This filter removes a station logo at position 90×945 with a width and height of 85 pixels.
delogo=x=90:y=945:w=85:h=85
Now we need to add the filter to the FFmpeg command using -vf:
./ffmpeg -i InputVideo.mp4 -vf delogo=x=90:y=945:w=85:h=85 OutputVideo.mp4
And this is the result:
Was easy, right?
Troubleshooting
Sometimes the logo is still visible in the output file. Then you should check the parameters x/y for the position (maybe another position in the video is blurred) or the value for width and height should be increased.
If you have no idea where the filter is applied you can append the parameter:
show=1
./ffmpeg -i InputVideo.mp4 -vf delogo=x=90:y=945:w=85:h=85:show=1 OutputVideo.mp4
Then the square is surrounded by a green box.
For testing you can also add the FFmpeg parameter -t 15 to encode just the first 15 seconds.
./ffmpeg -i InputVideo.mp4 -vf delogo=x=90:y=945:w=85:h=85:show=1 -t 15 OutputVideo.mp4
Very good! Thank you!
Thank you very much for the information. So I was able to remove 3 white and one green hot pixel from a nightly video that is 9.65GB in size. The original 4K video shows fireworks shot with a Nikon D850 and a Samyang 35mm F/1.4 lens. The MacBook Air M2 was fully utilized with its 8 CPU cores. (fps= 10)
Great to hear.
Depending on the codec you use, you can maybe improve the performance on your MacBook by using hardware encoding.
Check out the following post for more details:
https://www.martin-riedl.de/2020/12/06/using-hardware-acceleration-on-macos-with-ffmpeg/
Yes, I know that. With the hardware encoder it is 5x faster. The problem is that the hardware encoder is trimmed for speed and unfortunately not for good image quality.
Such a nice option with “show”!
Thank you friend, this guide is useful.
thanks, but how to delogo just at the specific time, for example 10min video but logo shown at first 1 minute, and after there is no logo and i dont want to have the rest video being degradated for nothing. thanks again!