A Go backend with a Next.js frontend that leverages OpenAI to censor videos based on age categories (6+, 12+, 16+, 18+). Supports blurring, trimming, and muting inappropriate content based on the selected age filter.
https://www.youtube.com/watch?v=epCRTlCXfpU&t=121s
Before testing the application, ensure you have the following installed:
- Go 1.23.3 or higher - Download Go
- Node.js 18.0 or higher - Download Node.js
- npm or yarn - Comes with Node.js
- OpenCV - Required for video processing
- FFmpeg - Required for video manipulation
brew install opencvsudo apt update
sudo apt install libopencv-devFollow the OpenCV installation guide
brew install ffmpegsudo apt update
sudo apt install ffmpegDownload from FFmpeg official website
git clone https://github.com/agam1092005/censor-ai.git
cd censor-aicd backendCreate a .env file in the backend directory with your OpenAI API key:
echo "OPENAI_API_KEY=your_openai_api_key_here" > .envImportant: Replace your_openai_api_key_here with your actual OpenAI API key from OpenAI Platform
go mod downloadgo run main.goThe backend server will start on http://localhost:8000
You should see:
Starting server on port 8000...
[GIN] Listening on :8000
cd frontendnpm install
# or
yarn installnpm run dev
# or
yarn devThe frontend will start on http://localhost:3000
Open your web browser and navigate to http://localhost:3000
For testing purposes, you can use any of the following types of videos:
- Family-friendly content (should get 6+ rating)
- Mild content (should get 12+ rating)
- Moderate content (should get 16+ rating)
- Mature content (should get 18+ rating)
- Format: MP4, AVI, MOV, or other common video formats
- Size: Maximum 20MB
- Duration: Shorter videos (1-5 minutes) work best for testing
- Content: Videos with varying content levels to test different age ratings
- Use your own video files
- Download sample videos from:
- Sample Videos
- Big Buck Bunny (family-friendly)
- Create short screen recordings for testing
- On the main page, you'll see a drag-and-drop area
- Either:
- Drag and drop a video file onto the upload area
- Click the upload area to select a file from your computer
- After uploading, click the "Analyze Video" button
- The application will:
- Upload the video to the backend
- Process the video frame by frame
- Use OpenAI to analyze content appropriateness
- Return age ratings for different segments
- Choose Age Rating: Select from 6+, 12+, or 16+
- Choose Processing Method:
- Blur: Blurs inappropriate sections while keeping audio
- Trim: Removes inappropriate sections entirely (auto-selected for 6+)
- Click "Process Video"
- Wait for processing to complete
- Download the processed video
- Small videos (< 1MB): 30 seconds - 2 minutes
- Medium videos (1-5MB): 2-5 minutes
- Large videos (5-20MB): 5-15 minutes
Processed videos are saved in backend/processed/ with timestamps
- ✅ Video uploads successfully
- ✅ Analysis completes without errors
- ✅ Age ratings are returned
- ✅ Processing completes successfully
- ✅ Processed video can be downloaded
Backend won't start:
- Check if OpenCV is properly installed
- Verify Go version (1.23.3+)
- Ensure port 8000 is not in use
Frontend won't start:
- Check Node.js version (18.0+)
- Run
npm installagain - Ensure port 3000 is not in use
Video upload fails:
- Check file size (max 20MB)
- Verify video format is supported
- Ensure both backend and frontend are running
OpenAI API errors:
- Verify API key is correct in
.envfile - Check OpenAI account has credits
- Ensure internet connection is stable
Video processing fails:
- Check FFmpeg is installed and in PATH
- Verify enough disk space for processing
- Check video file is not corrupted
You can also test the backend directly:
Upload endpoint:
curl -X POST -F "video=@/path/to/your/video.mp4" http://localhost:8000/uploadConvert endpoint:
curl -X POST http://localhost:8000/convert \
-H "Content-Type: application/json" \
-d '{
"age": "12",
"ratings": [{"start": 0, "end": 10, "rating": "12+", "notes": "mild content"}],
"video_type": "blur",
"video_path": "uploads/your_video.mp4"
}'- Start both servers (backend on :8000, frontend on :3000)
- Upload a test video (try a 1-2 minute video first)
- Analyze the video and wait for ratings
- Select age rating (try 12+ first)
- Choose processing type (try "blur" first)
- Process the video and download result
- Verify the output by playing the processed video
The project includes GPT-OSS integration for intelligent content classification that provides overall content ratings based on video metadata, audio transcripts, and vision analysis.
cd backend
./setup_gpt_oss.shOr manually:
pip3 install -r requirements.txtFor best results, set your OpenAI API key:
export OPENAI_API_KEY="your-openai-api-key"If no API key is provided, the system automatically uses offline Hugging Face models.
cd backend
python3 test_gpt_oss.pyThis will test:
- Direct Python classifier functionality
- Go backend integration
- Different content type classifications
Standalone Classification:
curl -X POST http://localhost:8000/classify \
-H "Content-Type: application/json" \
-d '{
"metadata": {"filename": "test.mp4", "duration": 120},
"transcript": "Family-friendly adventure story with no violence",
"vision_labels": ["adventure", "family", "outdoor"]
}'Enhanced Video Upload:
curl -X POST http://localhost:8000/upload -F "video=@your_video.mp4"The response now includes both frame-by-frame analysis and overall GPT-OSS classification:
{
"ratings": [...],
"gpt_oss": {
"rating": "12+",
"reason": "Moderate action content suitable for ages 12 and above"
}
}Run the comprehensive demo:
cd backend
./demo_gpt_oss.shThis demonstrates classification with different content types and shows the complete integration workflow.
- Dual Backend Support: OpenAI API (online) or Hugging Face (offline)
- Intelligent Classification: Analyzes metadata, transcripts, and vision labels
- Age Ratings: Returns 6+, 12+, 16+, or 18+ with explanations
- Automatic Integration: Works alongside existing video processing
- Fallback Support: Graceful degradation if classification fails
Import Errors:
pip3 install openai transformers torchModel Loading Issues:
- First-time Hugging Face model download may take 5-10 minutes
- Models automatically fallback to CPU if CUDA unavailable
- Check available disk space (models require 1-5GB)
API Errors:
- Verify
OPENAI_API_KEYis correctly set - Check OpenAI account credits and rate limits
- System will automatically fallback to offline models