feat: Add subtitle generation and editing system #120
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Description
This PR introduces a comprehensive subtitle generation and editing system that allows users to upload videos, generate AI-powered subtitles using Google Gemini AI, edit subtitles in real-time, and download videos with burned-in subtitles. The implementation includes both backend API endpoints (NestJS) and a complete frontend interface (Next.js) with advanced subtitle editing capabilities.
Key Features:
🎯 Type of Change
🔗 Related Issue
🧪 Testing
📋 Checklist
📸 Screenshots (if applicable)
🔧 Technical Details
Backend Implementation
New Module: Subtitle Module (
apps/api/src/subtitle/)SubtitleController: REST API endpoints for subtitle operations
POST /subtitle- Create subtitle generation jobGET /subtitle- Get user's subtitle jobs (latest 10)GET /subtitle/:id- Get specific subtitlePOST /subtitle/upload- Upload video filePATCH /subtitle/:id- Update subtitle dataDELETE /subtitle/:id- Delete subtitle and videoPOST /subtitle/burn- Generate video with burned subtitlesSubtitleService: Core business logic
DTOs: Data transfer objects for API requests
Utilities: Helper functions for video processing
Frontend Implementation
New Pages:
/dashboard/subtitles- Main listing page with uploader and history/dashboard/subtitles/[id]- Subtitle editor page with video playerNew Components:
New Hooks:
useSubtitleGeneration- Manages subtitle generation workflowuseSubtitleData- Handles subtitle data fetching and stateuseSubtitleEditor- Manages subtitle editing operationsuseSubtitleFileOperations- Handles save, download, upload operationsuseVideoPlayer- Manages video player state and synchronizationuseDebounce- Generic debounce hook for performanceNew Utilities:
Refactored:
api-client.ts: Migrated from nativefetchtoaxiosfor better file upload support, interceptors, and error handlingNew Dependencies:
@google/genai,fluent-ffmpeg,@ffmpeg-installer/ffmpeg,@ffprobe-installer/ffprobe,multerTechnical Decisions
🚀 Deployment Notes
Required Environment Variables:
GOOGLE_GENERATIVE_AI_API_KEY- Google Generative AI API keyDatabase Schema Requirements:
subtitle_jobstable with columns: id, user_id, video_path, video_url, subtitles_json, status, language, detected_language, target_language, duration, error_message, created_at, updated_atStorage Requirements:
video_subtitlesfor video file storageServer Requirements:
@ffmpeg-installer/ffmpeg)📚 Documentation Updates
🔍 Review Notes
Areas to focus on during review:
subtitle.service.ts): Core logic for AI generation and video processing - review error handling and credit managementapi-client.ts): Migration from fetch to axios - ensure backward compatibilityPotential Questions:
📊 Performance Impact
Performance Improvements:
Performance Considerations:
🔒 Security Considerations
Security Measures:
SupabaseAuthGuardSecurity Notes:
🎉 Additional Notes
Future Improvements:
Migration Notes:
subtitle_jobstable (if not already created)🔗 Related Issue
Closes #77