U.F. AI Enhancer

Enhance Your Videos with AI

U.F. AI Enhancer is an offline tool that improves video quality by adjusting brightness, contrast, and sharpness using computer vision techniques.

Upload & Process

Your video will appear here

Enhancement Settings

Darker Normal Brighter
Lower Normal Higher
Softer Normal Sharper

Key Features

Brightness Adjustment

Fine-tune the brightness levels to make your videos clearer in low-light conditions or tone down overexposed footage.

Contrast Enhancement

Improve the distinction between light and dark areas to make your videos pop with better visual depth.

Sharpness Control

Reduce blurriness and enhance edge definition for crisper, more professional-looking videos.

How It Works

1

Upload Your Video

Select any video file from your device. The tool supports common formats like MP4, AVI, and MOV.

2

Adjust Enhancement Settings

Use the intuitive sliders to customize brightness, contrast, and sharpness levels to your preference.

3

Process & Download

The AI processes each frame to apply your enhancements, then outputs a new, improved video file.

Python Implementation

Below is the complete Python code for the U.F. AI Enhancer. This offline tool uses OpenCV for frame-by-frame processing and MoviePy for final rendering.

import cv2
import numpy as np
from moviepy.editor import VideoFileClip, VideoClip
import os
import time

class VideoEnhancer:
    def __init__(self):
        """Initialize the video enhancer with default settings."""
        self.brightness = 0    # Range: -100 to 100
        self.contrast = 0      # Range: -100 to 100
        self.sharpness = 50    # Range: 0 to 100
        self.filter_preset = "none"  # Options: none, vivid, cinematic, blackwhite
        
    def apply_enhancements(self, frame):
        """Apply all selected enhancements to a single frame.
        
        Args:
            frame: Input frame (numpy array)
            
        Returns:
            Enhanced frame (numpy array)
        """
        # Convert frame to float for processing
        frame = frame.astype('float32') / 255.0
        
        # Apply brightness and contrast
        frame = self.adjust_brightness_contrast(frame)
        
        # Apply sharpness
        frame = self.apply_sharpness(frame)
        
        # Apply filter preset
        frame = self.apply_filter(frame)
        
        # Convert back to 8-bit
        frame = (frame * 255).astype('uint8')
        
        return frame
    
    def adjust_brightness_contrast(self, frame):
        """Adjust brightness and contrast of the frame.
        
        Args:
            frame: Input frame (float32, 0-1 range)
            
        Returns:
            Adjusted frame (float32, 0-1 range)
        """
        # Convert brightness/contrast values to multipliers
        brightness_factor = (self.brightness + 100) / 100.0
        contrast_factor = (self.contrast + 100) / 100.0
        
        # Apply brightness
        frame = frame * brightness_factor
        
        # Apply contrast
        frame = ((frame - 0.5) * contrast_factor) + 0.5
        
        # Clip values to 0-1 range
        frame = np.clip(frame, 0, 1)
        
        return frame
    
    def apply_sharpness(self, frame):
        """Apply sharpness enhancement to the frame.
        
        Args:
            frame: Input frame (float32, 0-1 range)
            
        Returns:
            Sharpened frame (float32, 0-1 range)
        """
        if self.sharpness == 50:  # No sharpness adjustment
            return frame
            
        # Convert sharpness to a kernel strength (0-2 range)
        strength = self.sharpness / 50.0
        
        # Create sharpening kernel
        kernel = np.array([[-1, -1, -1],
                           [-1,  9, -1],
                           [-1, -1, -1]]) * strength
        
        # Apply convolution
        sharpened = cv2.filter2D(frame, -1, kernel)
        
        # Blend with original based on strength
        alpha = min(1.0, abs(strength - 1.0))
        frame = alpha * sharpened + (1 - alpha) * frame
        
        return np.clip(frame, 0, 1)
    
    def apply_filter(self, frame):
        """Apply selected filter preset to the frame.
        
        Args:
            frame: Input frame (float32, 0-1 range)
            
        Returns:
            Filtered frame (float32, 0-1 range)
        """
        if self.filter_preset == "vivid":
            # Boost saturation and contrast
            hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
            hsv[..., 1] = hsv[..., 1] * 1.5  # Increase saturation
            frame = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
            frame = np.clip(frame, 0, 1)
            
        elif self.filter_preset == "cinematic":
            # Add a slight blue tint and reduce brightness
            frame[..., 0] = frame[..., 0] * 0.9  # Reduce blue slightly
            frame[..., 2] = frame[..., 2] * 1.1  # Increase red slightly
            frame = frame * 0.9  # Darken slightly
            frame = np.clip(frame, 0, 1)
            
        elif self.filter_preset == "blackwhite":
            # Convert to grayscale then back to BGR for consistent processing
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            frame = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
            
        return frame
    
    def process_video(self, input_path, output_path):
        """Process the entire video file with the current settings.
        
        Args:
            input_path: Path to input video file
            output_path: Path to save enhanced video file
            
        Returns:
            Processing time in seconds
        """
        start_time = time.time()
        
        # Load the video
        clip = VideoFileClip(input_path)
        
        # Define the processing function for each frame
        def process_frame(frame):
            return self.apply_enhancements(frame)
        
        # Apply the processing to each frame
        enhanced_clip = clip.fl_image(process_frame)
        
        # Write the result to a file
        enhanced_clip.write_videofile(
            output_path,
            codec='libx264',
            audio_codec='aac',
            threads=4,
            fps=clip.fps,
            bitrate=f"{int(clip.size[0] * clip.size[1] * clip.fps * 0.1)}k"
        )
        
        # Close the clips
        clip.close()
        enhanced_clip.close()
        
        return time.time() - start_time

def main():
    """Main function to demonstrate the video enhancement."""
    print("U.F. AI Enhancer - Video Quality Improvement Tool")
    print("-----------------------------------------------")
    
    # Initialize enhancer
    enhancer = VideoEnhancer()
    
    # Get input file
    input_file = input("Enter path to input video file: ").strip('"')
    if not os.path.exists(input_file):
        print("Error: File not found!")
        return
    
    # Set output file
    output_file = os.path.splitext(input_file)[0] + "_enhanced.mp4"
    
    # Get enhancement settings from user
    print("\nEnhancement Settings (press Enter for defaults)")
    print("--------------------------------------------")
    
    try:
        brightness = input(f"Brightness (-100 to 100) [default {enhancer.brightness}]: ")
        if brightness: enhancer.brightness = int(brightness)
        
        contrast = input(f"Contrast (-100 to 100) [default {enhancer.contrast}]: ")
        if contrast: enhancer.contrast = int(contrast)
        
        sharpness = input(f"Sharpness (0 to 100) [default {enhancer.sharpness}]: ")
        if sharpness: enhancer.sharpness = int(sharpness)
        
        print("\nFilter Presets:")
        print("1. None (default)")
        print("2. Vivid Colors")
        print("3. Cinematic")
        print("4. Black & White")
        filter_choice = input("Select filter (1-4) [default 1]: ")
        if filter_choice == "2": enhancer.filter_preset = "vivid"
        elif filter_choice == "3": enhancer.filter_preset = "cinematic"
        elif filter_choice == "4": enhancer.filter_preset = "blackwhite"
        
        # Process the video
        print("\nProcessing video... This may take some time depending on video length.")
        processing_time = enhancer.process_video(input_file, output_file)
        
        print(f"\nProcessing complete! Enhanced video saved to: {output_file}")
        print(f"Processing time: {processing_time:.2f} seconds")
        
    except ValueError:
        print("Error: Invalid input! Please enter numbers only for settings.")
    except Exception as e:
        print(f"An error occurred: {str(e)}")

if __name__ == "__main__":
    main()

Requirements

To run this tool, you'll need to install the following Python packages:

pip install opencv-python numpy moviepy

For better performance, you can also install FFmpeg:

# On Windows: choco install ffmpeg
# On macOS: brew install ffmpeg
# On Linux (Debian/Ubuntu): sudo apt install ffmpeg

Made with DeepSite LogoDeepSite - 🧬 Remix