Complete video optimization tool with: - 21 platform configurations (Meta, TikTok, YouTube, Pinterest, Snapchat, Amazon) - FFmpeg-powered video conversion with H264, H265, and VP9 codecs - Python Flask backend with REST API - HTML/JS frontend with drag-drop interface - Black + #FFC407 color scheme with Montserrat font - Side-by-side video comparison player - Filename auto-detection for platform and aspect ratio - MAMP-compatible setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6.9 KiB
MAMP Setup Guide
Overview
This guide explains how to run the Video Optimizer with MAMP hosting the frontend while the Python backend runs separately.
Architecture
MAMP (Port 8888) Python Flask (Port 5000)
↓ ↓
Frontend (HTML/JS) ←→ API Calls → Backend (Video Processing)
The frontend runs on MAMP, but makes API calls to the Python backend for video processing.
Step 1: Setup Python Backend
1.1 Activate Virtual Environment
cd /Users/daveporter/Desktop/CODING-2024/Loreal-FIle-Reduction
source venv/bin/activate
1.2 Start Backend Server
cd backend
python app.py
You should see:
Starting Video Optimization Server...
Upload folder: .../backend/uploads
Output folder: .../backend/outputs
* Running on http://0.0.0.0:5000
Keep this terminal running! The backend must stay active.
Step 2: Configure MAMP
2.1 Open MAMP Preferences
- Open MAMP application
- Go to Preferences > Ports
- Verify Apache Port (usually 8888 or 80)
2.2 Set Document Root
- Go to Preferences > Web Server
- Click "Select" next to Document Root
- Navigate to:
/Users/daveporter/Desktop/CODING-2024/Loreal-FIle-Reduction/frontend - Click "Select"
2.3 Start MAMP
- Click "Start Servers"
- Wait for Apache and MySQL to turn green
Step 3: Configure API Endpoint
3.1 Edit config.js
Open frontend/config.js and ensure it points to your Python backend:
const CONFIG = {
// Python Flask backend URL - MUST be running!
API_BASE: 'http://localhost:5000/api',
MAX_FILE_SIZE: 500 * 1024 * 1024,
DEBUG: true
};
3.2 Verify Configuration
The default port 5000 should work. If your Python backend is on a different port, update this line.
Step 4: Access the Application
Open in Browser
Navigate to: http://localhost:8888/index.html
Or if MAMP is on port 80: http://localhost/index.html
Step 5: Test the Connection
5.1 Check Backend Health
Open browser console (F12) and run:
fetch('http://localhost:5000/api/health')
.then(r => r.json())
.then(d => console.log(d))
Should return:
{
"status": "ok",
"ffmpeg_installed": true,
"timestamp": "2025-..."
}
5.2 Upload a Test Video
- Drag and drop a video file
- Check browser console for any errors
- Verify backend terminal shows upload activity
Common Issues & Solutions
Issue 1: "Failed to fetch" Error
Problem: Frontend can't reach backend
Solutions:
-
Check backend is running:
ps aux | grep "python.*app.py" -
Test backend directly:
curl http://localhost:5000/api/health -
Check CORS settings in
backend/app.py:CORS(app) # Should be present -
Verify port 5000 is not blocked:
lsof -i :5000
Issue 2: CORS Errors
Symptom: Console shows "CORS policy" errors
Solution: Ensure backend/app.py has:
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
Already included! If still having issues, try:
CORS(app, resources={r"/api/*": {"origins": "*"}})
Issue 3: Backend Not Starting
Error: Port 5000 already in use
Solution:
# Find process using port 5000
lsof -ti:5000
# Kill it
lsof -ti:5000 | xargs kill
# Or use a different port
python app.py --port 5001
Then update frontend/config.js:
API_BASE: 'http://localhost:5001/api'
Issue 4: File Upload Fails
Symptom: Upload shows error or times out
Check:
-
File size limit (default 500MB):
// In config.js MAX_FILE_SIZE: 500 * 1024 * 1024 -
Backend upload folder exists:
ls -la backend/uploads/ -
Permissions:
chmod 755 backend/uploads chmod 755 backend/outputs
Alternative: Direct File Access
If you prefer not to use MAMP, you can open the HTML directly:
# Open with default browser
open frontend/index.html
# Or
# Just drag index.html into your browser
Important: Some browsers restrict file:// protocol. Chrome/Safari should work fine.
Development Workflow
Typical Setup:
Terminal 1 - Backend:
cd /Users/daveporter/Desktop/CODING-2024/Loreal-FIle-Reduction
source venv/bin/activate
cd backend
python app.py
MAMP:
- Document Root:
.../frontend - Apache running on port 8888
- Access: http://localhost:8888/index.html
Browser:
- Open http://localhost:8888/index.html
- Open DevTools (F12) to monitor API calls
Debugging Tips
Enable Debug Mode
In frontend/config.js:
DEBUG: true
In backend/app.py:
app.run(debug=True, host='0.0.0.0', port=5000)
Monitor Network Requests
- Open browser DevTools (F12)
- Go to Network tab
- Upload a file
- Check API calls to
localhost:5000
Check Backend Logs
Watch the terminal running python app.py for:
- Upload confirmations
- Conversion progress
- Error messages
Production Considerations
For production deployment:
- Change API_BASE in config.js to your production URL
- Disable DEBUG mode
- Use production WSGI server (Gunicorn, uWSGI)
- Set up proper CORS restrictions
- Configure SSL/HTTPS
- Implement authentication if needed
Quick Troubleshooting Commands
# Check if backend is running
curl http://localhost:5000/api/health
# Check if MAMP is serving files
curl http://localhost:8888/index.html
# Test backend upload endpoint
curl -X POST http://localhost:5000/api/platforms
# View backend logs
cd backend
python app.py # Watch terminal output
# Check FFmpeg
ffmpeg -version
# List processes
ps aux | grep -E "(python|httpd)"
File Structure for MAMP
MAMP Document Root → /frontend/
├── index.html ← Entry point
├── style.css
├── app.js
└── config.js ← Configure API endpoint here
Python Backend → /backend/
├── app.py ← Must be running (port 5000)
├── video_processor.py
├── platform_specs.py
├── uploads/ ← Auto-created
└── outputs/ ← Auto-created
Success Checklist
- Python backend running on port 5000
- MAMP Apache running
- MAMP Document Root set to
frontend/folder config.jshas correct API_BASE URL- Can access http://localhost:8888/index.html
- Browser console shows no CORS errors
- Test upload works
- FFmpeg installed and detected
Need Help?
- Check backend terminal for errors
- Check browser console (F12) for JavaScript errors
- Test backend directly:
curl http://localhost:5000/api/health - Verify MAMP is serving files:
curl http://localhost:8888/index.html
The key: Python backend MUST be running for video processing to work!