- Created FileCleanup utility class to manage old upload files - Automatically removes files older than 24 hours on each request - Added cleanup calls to both estimate.php and uploader.php processes - Includes detailed logging and statistics for cleanup operations - Provides formatBytes utility for human-readable file size reporting - Includes directory statistics functionality for monitoring This prevents the uploads directory from growing indefinitely and ensures proper disk space management for the video processing system. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| uploads | ||
| .gitignore | ||
| api_client.php | ||
| cleanup.php | ||
| estimate.php | ||
| favicon.ico | ||
| index.php | ||
| logger.php | ||
| process.php | ||
| README.md | ||
| status.php | ||
| TOPAZ-VIDEO.svg | ||
| uploader.php | ||
Video Enhancement Portal
A PHP-based web application that integrates with the Topaz Labs Video AI API to provide professional video enhancement services. This portal allows users to upscale, enhance, and improve video quality using advanced AI models.
🎯 Features
-
Multiple Enhancement Models: Support for various Topaz Labs AI models including:
- Proteus Beta (prob-4)
- Apollo (apo-8)
- Artemis High Quality (ahq-12)
- Artemis Medium Quality (amq-13)
- Theia Detail (thd-3)
- Theia Fidelity (thf-4)
- Nyx Night Vision (nyx-3)
- Gaia CG Enhancement (gcg-5)
- Gaia High Quality (ghq-5)
-
Video Resolution Scaling: Original, 2x, and 4x upscaling options
-
Advanced Enhancement Controls: Fine-tune blur reduction, grain, grain size, and detail recovery
-
Real-time Progress Tracking: Live progress updates during video processing
-
Cost Estimation: Get processing time and credit estimates before starting
-
Dark/Light Theme: Toggle between dark and light UI modes
-
Microsoft Authentication: Secure login integration with Microsoft Identity Platform
-
Responsive Design: Modern, mobile-friendly interface
📋 Requirements
System Requirements
- Web Server: Apache/Nginx with PHP support
- PHP: Version 7.4 or higher
- PHP Extensions:
curl- For API communicationjson- For data processingsession- For session managementfileinfo- For file type detection
External Dependencies
- Topaz Labs API: Valid API key required
- Microsoft Azure AD: For authentication (optional)
🚀 Installation
1. Clone or Download
# If using git
git clone <repository-url> video-upscaler
cd video-upscaler
# Or download and extract the files to your web server directory
2. Web Server Configuration
Apache
Ensure your .htaccess file in the uploads/ directory contains:
# Deny access to uploaded files for security
Order deny,allow
Deny from all
Nginx
Add to your server configuration:
location /uploads/ {
deny all;
return 403;
}
3. Directory Permissions
# Make uploads directory writable
chmod 755 uploads/
chown www-data:www-data uploads/ # For Apache
# or
chown nginx:nginx uploads/ # For Nginx
4. Configuration Setup
Update API Configuration
Edit config.php and update the API key:
const API_KEY = 'your-topaz-labs-api-key-here';
Microsoft Authentication (Optional)
If using Microsoft authentication, update the values in index.php:
const msalConfig = {
auth: {
clientId: "your-client-id",
authority: "https://login.microsoftonline.com/your-tenant-id",
redirectUri: "https://your-domain.com/your-path"
}
};
5. PHP Configuration
Ensure your php.ini has appropriate settings:
# For large video files
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300
memory_limit = 256M
# For session management
session.auto_start = 0
session.use_cookies = 1
6. SSL/HTTPS Setup (Recommended)
This application handles file uploads and authentication, so HTTPS is strongly recommended:
Let's Encrypt (Free SSL)
# Install certbot
sudo apt install certbot python3-certbot-apache # For Apache
# or
sudo apt install certbot python3-certbot-nginx # For Nginx
# Get certificate
sudo certbot --apache -d yourdomain.com # For Apache
# or
sudo certbot --nginx -d yourdomain.com # For Nginx
🔧 Configuration
Environment Variables (Optional)
Create a .env file for additional configuration:
TOPAZ_API_KEY=your-api-key-here
LOG_LEVEL=INFO
UPLOAD_MAX_SIZE=500M
Logging
Logs are written to app.log. Monitor this file for debugging:
tail -f app.log
File Upload Limits
Adjust based on your expected video file sizes in config.php or server configuration.
📖 Usage
For End Users
- Access the Portal: Navigate to your installation URL
- Authentication: Log in using Microsoft credentials (if enabled)
- Upload Video: Select your video file for enhancement
- Choose Settings:
- Select enhancement model
- Choose output resolution
- Adjust enhancement parameters (blur, grain, etc.)
- Get Estimate: Click "Get Estimate" to see processing time and cost
- Process Video: Confirm and start processing
- Monitor Progress: Watch real-time progress updates
- Download: Download your enhanced video when complete
For Administrators
Monitoring
- Check
app.logfor processing status and errors - Monitor disk space in
uploads/directory - Review PHP error logs
Maintenance
# Clean up old temporary files (run as cron job)
find uploads/ -type f -mtime +7 -delete
# Monitor log file size
ls -lh app.log
🔒 Security Considerations
File Upload Security
- Upload directory is protected from direct access
- File types are validated on client and server side
- Temporary files are cleaned up after processing
Authentication
- Microsoft Identity Platform integration
- Session-based authentication
- HTTPS recommended for production
API Key Protection
- Store API keys securely
- Consider using environment variables
- Rotate keys regularly
🐛 Troubleshooting
Common Issues
"No video request found in session"
- Check PHP session configuration
- Ensure cookies are enabled
- Verify session directory is writable
Upload fails
- Check file size limits in PHP configuration
- Verify upload directory permissions
- Check disk space
API errors
- Verify API key is valid
- Check network connectivity to Topaz Labs API
- Review API rate limits
Authentication issues
- Verify Microsoft app registration settings
- Check redirect URIs match configuration
- Ensure tenant ID is correct
Log Analysis
# View recent errors
grep ERROR app.log | tail -10
# Monitor real-time activity
tail -f app.log | grep -E "(ERROR|WARN)"
📚 API Reference
This application integrates with the Topaz Labs Video AI API. Key endpoints used:
POST /video/estimate- Get processing estimatesPOST /video/request- Create processing requestPUT /video/upload- Upload video partsPOST /video/complete- Complete uploadGET /video/status- Check processing status
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
📄 License
This project is for internal/educational use. Check Topaz Labs terms of service for API usage restrictions.
🆘 Support
For issues and questions:
- Check the troubleshooting section above
- Review application logs (
app.log) - Consult Topaz Labs API documentation
- Contact system administrator
🔄 Version History
- v1.0: Initial release with basic enhancement features
- v1.1: Added Microsoft authentication
- v1.2: Enhanced UI with dark mode and better progress tracking
- v1.3: Improved error handling and logging
⚠️ Production Notice: This application is marked as a sandbox/development tool. For production use, additional security hardening and testing is recommended.