Removing the logo from a video stream can be achieved using the ffmpeg 'delogo' video filter. ffmpeg is a cross platform command line utility but very powerfull. Its library 'libffmpeg' is used as a backend by many graphical video editors.
I wanted to automatically convert a lot of video captures to my preffered resolotion and encoding and while doing this I also wanted to get rid of the TV station logo. These logos come in a variaty of shapes and sizes and are placed in variour corners of the screen.
The ffmpeg delogo filter takes 5 parameters: the X,Y position and the W,H sizes of the blured rectangle and an optional border width. To automate the finding of these parameters I wrote a C program which searches for the logo and prints a string ready for ffmpeg use. It also detects any black bands and prints another string to be passed to the 'crop' filter.
A typical output from the 'delogo' program looks like this:
Size: 1920x1080 crop=1920:822:0:129 delogo=x=1799:y=986:w=106:h=79 corner 3 Duration: 1148.78 BitRate: 9574795
Detecting the logo takes about 5 seconds on my machine and then I'm using a Perl script which builds all the required ffmpeg parameters from its output.
The program C code and the compiled linux executable are here.
The detection algorithm starts by getting equally spaced timestamps of the input video file (64 by default). Then from those timestamps it searches the first key frames and saves the Y plane of those frames (for YUV 4:2:0 and 4:2:2 encodings). To speed detection only the 4 corners of an image are saved while the middle bands are discarded. The percentage of these corners are configurable with switch options.
To find the logo position all the saved frames are cross-correlated and the constant pixels will emerge. For static videos sometimes the detection fails and then it is better to apply first and edge detection algorithm (Canny) and cross-correlate the edges.

The following switches can be passed to the program:
Usage: delogo [options] video_file -?,--help show options help -i,--info show video info only -y,--canny force canny edge detection for logo -2,--two_rectangles cover the logo with two overlaping rectangles -m,--removelogo generate a mask of the logo instead of a rectangle -r,--pixel_ratio switch to mask mode if pixel percentage inside the logo bounding box is bellow (default 0%) -c,--corner fix logo corner [0-3] (NW,NE,SW,SE) -f,--frames number of frames to process (default 64) -W,--width_bands width percentage search band (default 35%) -H,--height_bands height percentage search band (default 18%) -b,--level_black maximum black level (default 23) -d,--level_delta maximum luminance distace for logo detection (default 65) -k,--border_black border thickness around logo (default 15) -z,--border_band additional border band (default 4) -t,--threshold canny edge detection threshold 0-255 (default 170) -s,--sigma canny sigma (default 1.2) -l,--tlow canny tlow (default 0.3) -h,--thigh canny thigh (default 0.8) -X,--save_as_pcx save images as PCX rather than PNG
Simple Correlation | Canny Edge Correlation |
![]() | ![]() |
Before | After |
![]() | ![]() |