Skip to content

yusufadeagbo/HideAnything

Repository files navigation

Video Logo Remover 🎬

A fast, reliable Python tool for removing logos and watermarks from videos by covering specific regions. Uses intelligent color sampling and blending for natural-looking results. Preserves audio and maintains high video quality.

Features ✨

  • Region-based removal - Specify exact areas to cover (no ML detection needed)
  • πŸ”Š Audio preservation - Keeps original audio intact
  • 🎯 High quality output - Near-lossless video encoding (CRF 18)
  • Flexible coordinates - Use percentages (85%) or pixels (1100)
  • Frame-specific timing - Control when each region is active
  • Smart color sampling - Automatically matches surrounding colors
  • Multiple methods - Color fill + blur or OpenCV inpainting
  • Batch processing - Use config files for complex setups
  • Preview mode - See regions before processing
  • Progress tracking - Real-time progress bar
  • Fast processing - No heavy ML models required

Installation πŸš€

Ubuntu/Linux

# Install system dependencies
sudo apt update
sudo apt install python3 python3-pip ffmpeg -y

# Install Python dependencies
pip3 install opencv-python numpy tqdm

# Or using requirements.txt
pip3 install -r requirements.txt

⚠️ Important: FFmpeg is required for audio preservation and high-quality encoding. Without it, the output will have no audio and reduced quality.

Verify Installation

# Check Python script
python3 remove_logo_regions.py --help

# Check FFmpeg
ffmpeg -version

Quick Start πŸƒ

1. Simple Logo Removal

Remove a logo from the bottom-right corner:

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%" \
    -o clean_video.mp4

2. Multiple Regions

Remove multiple logos with different timing:

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%,start=300,end=7320" \
    -r "x=42%,y=12%,w=15%,h=6%,start=0,end=300" \
    -o clean_video.mp4 \
    --preview

3. Using Pixel Values

For precise control, use pixel coordinates:

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=1100,y=650,w=150,h=50" \
    -o clean_video.mp4

4. Using Config File (Recommended for Complex Projects)

Create config.json:

{
  "regions": [
    {
      "x": "85%",
      "y": "90%",
      "w": "12%",
      "h": "6%",
      "start_frame": 0,
      "end_frame": 7320
    },
    {
      "x": "42%",
      "y": "12%",
      "w": "15%",
      "h": "6%",
      "start_frame": 0,
      "end_frame": 100
    }
  ],
  "use_inpainting": false,
  "blur_strength": 5
}

Then run:

python3 remove_logo_regions.py -v input.mp4 -c config.json -o clean_video.mp4

Usage Guide πŸ“–

Command Line Options

Option Short Description
--video -v Required. Input video file path
--output -o Output video file (default: output.mp4)
--region -r Region specification (can use multiple times)
--config -c Load regions from JSON config file
--inpaint -i Use OpenCV inpainting instead of color fill
--blur -b Blur strength (odd number, default: 5)
--margin -m Margin for color sampling (default: 15 pixels)
--preview -p Preview regions before processing

Region Format

Regions use comma-separated key=value pairs:

x=VALUE,y=VALUE,w=VALUE,h=VALUE[,start=FRAME,end=FRAME]

Parameters:

  • x - X coordinate (left edge)
  • y - Y coordinate (top edge)
  • w - Width
  • h - Height
  • start - Starting frame (optional, default: 0)
  • end - Ending frame (optional, default: last frame)

Values can be:

  • Percentages: x=85% (85% from left edge)
  • Pixels: x=1100 (1100 pixels from left edge)

Finding Region Coordinates

Method 1: Using Preview Mode

  1. Make an educated guess
  2. Use --preview to see the region
  3. Adjust and re-run until perfect
python3 remove_logo_regions.py -v input.mp4 -r "x=85%,y=90%,w=12%,h=6%" -p

Method 2: Using an Image Editor

  1. Extract a frame: ffmpeg -i input.mp4 -vframes 1 frame.png
  2. Open in GIMP/Photoshop and note coordinates
  3. Use pixel values in the command

Method 3: Common Logo Positions

Position Suggested Region
Bottom-right x=85%,y=90%,w=12%,h=6%
Bottom-left x=3%,y=90%,w=12%,h=6%
Top-right x=85%,y=3%,w=12%,h=6%
Top-left x=3%,y=3%,w=12%,h=6%
Top-center x=42%,y=3%,w=15%,h=6%

Advanced Examples πŸ”₯

Remove Logo That Appears Mid-Video

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%,start=500,end=7320" \
    -o clean_video.mp4

Multiple Logos with Different Timings

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%" \
    -r "x=10%,y=10%,w=8%,h=4%,start=0,end=200" \
    -r "x=50%,y=50%,w=10%,h=5%,start=1000,end=2000" \
    -o clean_video.mp4

Use Inpainting for Better Quality (Slower)

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%" \
    --inpaint \
    -o clean_video.mp4

Stronger Blur for Better Blending

python3 remove_logo_regions.py \
    -v input.mp4 \
    -r "x=85%,y=90%,w=12%,h=6%" \
    --blur 9 \
    -o clean_video.mp4

Video Quality Settings 🎨

The tool uses FFmpeg with high-quality encoding settings:

  • CRF 18: Near visually lossless (lower = better quality, 0 = lossless, 51 = worst)
  • Preset slow: Better compression efficiency
  • Audio: 320k AAC (high quality)

Adjusting Quality

To change quality settings, edit the _merge_audio_with_ffmpeg method in the script:

'-crf', '18',      # Change to 15 for higher quality, 23 for smaller files
'-preset', 'slow', # Change to 'medium' for faster encoding
'-b:a', '320k',    # Audio bitrate

Quality vs File Size:

  • CRF 15: Excellent quality, large files
  • CRF 18: Near-lossless, recommended (default)
  • CRF 23: Good quality, smaller files
  • CRF 28: Lower quality, much smaller files

Tips & Best Practices πŸ’‘

For Best Results

  1. Use percentages - They work across different resolutions
  2. Preview first - Always use --preview to verify regions
  3. Make regions slightly larger - Better to cover extra area
  4. Use blur - Default blur (5) works well, increase to 7 or 9 for better blending
  5. Try both methods - Color sampling is faster, inpainting is higher quality
  6. Ensure FFmpeg is installed - Required for audio and quality

Performance

  • Speed: Processes 1080p video at 30-60 FPS on modern hardware (frame processing)
  • Encoding: FFmpeg re-encoding adds ~1-2x video duration for final output
  • Memory: Low memory usage (~500MB for 1080p)
  • CPU only: No GPU required (but works faster with GPU-enabled OpenCV)

Troubleshooting

Problem: No audio in output video

  • Solution: Install FFmpeg: sudo apt install ffmpeg
  • Solution: Check that original video has audio: ffprobe input.mp4

Problem: Poor video quality

  • Solution: Install FFmpeg for high-quality encoding
  • Solution: Lower CRF value in script (e.g., 15 instead of 18)

Problem: Visible edges around covered region

  • Solution: Increase blur strength: --blur 7 or --blur 9
  • Solution: Increase margin: --margin 20

Problem: Wrong color used for covering

  • Solution: Adjust margin to sample from different area
  • Solution: Try inpainting method: --inpaint

Problem: Logo not fully covered

  • Solution: Make region slightly larger

Problem: Video not processing

  • Solution: Check video path and permissions
  • Solution: Ensure video codec is supported (MP4, AVI, MOV work best)

Problem: "FFmpeg not found" warning

File Structure πŸ“

logo_remover/
β”œβ”€β”€ remove_logo_regions.py    # Main script
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ LICENSE                    # MIT License
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ config.json.example        # Example config file
└── examples/                  # Example configs
    β”œβ”€β”€ bottom_right.json
    β”œβ”€β”€ multiple_regions.json
    └── timed_removal.json

System Requirements πŸ“‹

  • OS: Ubuntu 18.04+ (or any Linux distro with FFmpeg support)
  • Python: 3.7 or higher
  • FFmpeg: Required for audio and high quality
  • RAM: 2GB minimum (4GB+ recommended for HD videos)
  • CPU: Any modern CPU (faster = better)
  • Disk: Enough space for temporary files and output (~2x input video size)

Contributing 🀝

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests if applicable
  5. Commit: git commit -am 'Add feature'
  6. Push: git push origin feature-name
  7. Submit a Pull Request

Development Setup

git clone https://github.com/yourusername/video-logo-remover.git
cd video-logo-remover
sudo apt install ffmpeg  # Install FFmpeg
pip install -r requirements.txt

Code Style

  • Follow PEP 8
  • Add type hints
  • Document functions with docstrings
  • Keep functions focused and simple

License πŸ“„

MIT License - see LICENSE file for details.

FAQ ❓

Q: Can I remove animated logos?
A: Yes! As long as the logo stays in the same position, it will be covered.

Q: Will this work on 4K videos?
A: Yes, but processing will be slower. Consider using percentages for coordinates.

Q: Does the audio get preserved?
A: Yes! FFmpeg automatically copies audio from the original video at high quality (320k AAC).

Q: What if I don't have FFmpeg?
A: The tool will still work but without audio and with reduced video quality. Install FFmpeg for best results.

Q: Can I use this on live streams?
A: This tool is designed for video files. For live streams, you'd need real-time processing.

Q: Does this work with all video formats?
A: It works with most formats OpenCV supports (MP4, AVI, MOV, MKV, etc.).

Q: How do I convert frame numbers to timestamps?
A: Frame number = timestamp (seconds) Γ— FPS. Example: At 30 FPS, frame 300 = 10 seconds.

Q: Will the video quality be reduced?
A: No! With FFmpeg installed, the output uses CRF 18 (near visually lossless) encoding, maintaining excellent quality.

Q: Can I automate this for multiple videos?
A: Yes! Use a bash script:

#!/bin/bash
for video in *.mp4; do
    python3 remove_logo_regions.py -v "$video" -c config.json -o "clean_${video}"
done

Q: How large will the output file be?
A: With CRF 18, output files are typically 80-120% of the original size. You can reduce this by using CRF 23 in the script.

Support πŸ’¬

Acknowledgments πŸ™

  • OpenCV for video processing
  • FFmpeg for high-quality encoding and audio handling
  • tqdm for progress bars
  • The open source community

Changelog πŸ“

Version 1.1.0 (2025)

  • ✨ Audio preservation using FFmpeg
  • ✨ High-quality encoding with CRF 18
  • ✨ Automatic audio merging
  • ✨ Better quality output with H.264 encoding
  • ⚠️ FFmpeg now required for best results

Version 1.0.0 (2025)

  • Initial release
  • Region-based logo removal
  • Percentage and pixel coordinate support
  • Frame-specific timing
  • Config file support
  • Preview mode
  • Two removal methods (color sampling + inpainting)

Made with ❀️ for the open source community

Star ⭐ this repo if you find it useful!

About

Automatically cover or blur any area in a video with smart color blending.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors