相關資料
Help and generated by gpt-4o
MVP Backend System Requirements Specification (SRS)
Project Name: Anime Subtitle Search and Meme Frame Generator MVP
Technology Stack: Node.js, Express, SQLite, FFmpeg
Primary Use Case: Build a backend service that supports video subtitle search and frame extraction for creating memes.
1. Overview
The MVP backend system will enable the following core functionalities:
- Accept an anime video and a subtitle file (SRT).
- Extract frames from the video based on subtitle timings using FFmpeg.
- Provide a search interface to retrieve subtitle blocks and their corresponding frames.
- Allow users to vote on the most suitable frames for meme creation.
- Store all generated frames, subtitle data, and voting information in a structured and efficient manner.
2. Functional Requirements
2.1 Video and Subtitle Management
FR-1.1 Video Upload and Storage
- The system shall accept an anime video file (e.g., MP4) uploaded by the user or obtained from a source (e.g., YouTube).
- The video metadata (e.g., title, duration, file path) shall be stored in the
videos
table in the database.
- The uploaded video file shall be saved on the server's filesystem in a predefined folder structure.
FR-1.2 Subtitle File Upload and Parsing
- The system shall accept an SRT subtitle file associated with the uploaded video.
- The subtitle file shall be parsed, and each subtitle block (with start/end times and text) shall be stored in the
subtitles
table in the database, linked to the corresponding video.
2.2 Frame Extraction and Storage
FR-2.1 Subtitle to Frame Extraction
- The system shall use FFmpeg to extract frames from the video based on the timing of the subtitle blocks.
- The system shall generate frames at the midpoint of each subtitle block and ±1 second variations.
- The system shall store the extracted frames as PNG files in a structured directory format, organized by video and subtitle.
FR-2.2 Frame Storage in Database
- The system shall store the metadata of each generated frame (e.g., video ID, subtitle ID, frame time, file path) in the
frames
table.
- The system shall ensure the generated frames are accessible and retrievable based on subtitle search queries.
2.3 Subtitle Search and Frame Retrieval
FR-3.1 Subtitle Search
- The system shall provide an API that allows users to search for subtitles using keywords.
- The search results shall return subtitle blocks, including start/end times, subtitle text, and corresponding frames.
FR-3.2 Frame Retrieval
- For each searched subtitle block, the system shall return all associated frames (including variations) for display in the user interface.
- The system shall allow users to retrieve the file path of a specific frame to download or share the image.
2.4 Voting on Frames
FR-4.1 Voting API
- The system shall provide an API that allows users to upvote or downvote frames.
- Each vote shall be linked to a specific frame in the
votes
table, recording the user (or anonymous ID), vote type (upvote or downvote), and timestamp.
FR-4.2 Frame Ranking
- The system shall calculate the ranking of frames based on user votes and return the most popular frame for a specific subtitle block when requested.
3. Non-Functional Requirements
- The system shall process and generate frames in under 5 seconds for a 2-minute video clip.
- The search queries for subtitles shall return results in less than 1 second for keyword-based searches.
3.2 Scalability
- The system shall be designed to handle multiple video uploads and frame extractions concurrently.
3.3 Data Storage
- The system shall use SQLite for local development and testing to store video, subtitle, frame, and vote data. PostgreSQL may be used for future scalability.
- The extracted frames shall be stored in the filesystem under
/frames/{video_id}/{subtitle_id}/
.
3.4 Error Handling
- The system shall provide detailed error responses if the subtitle or video files are not valid or fail to process.
- The system shall handle API request errors with appropriate HTTP status codes (e.g., 400 Bad Request, 500 Internal Server Error).
4. API Specifications
4.1 Upload Video
- Method:
POST /api/videos
- Input:
- Video file (MP4, AVI, etc.)
- Video metadata (title, series, episode number)
- Output: Video ID, status (success/failure)
4.2 Upload Subtitle
- Method:
POST /api/subtitles
- Input:
- Subtitle file (SRT)
- Associated video ID
- Output: Subtitle processing status (success/failure)
4.3 Search Subtitles
- Method:
GET /api/subtitles/search
- Input:
- Output: List of subtitle blocks (start time, end time, text) and associated frames
4.4 Retrieve Frames for Subtitle
- Method:
GET /api/frames/{subtitle_id}
- Input:
- Output: List of frames (file paths, time stamps)
4.5 Vote on Frame
- Method:
POST /api/frames/{frame_id}/vote
- Input:
- Frame ID, vote type (upvote/downvote)
- Output: Vote status (success/failure)
5. Data Models
5.1 Video Model
5.2 Subtitle Model
5.3 Frame Model
5.4 Vote Model
6. Assumptions and Constraints
- The MVP will initially focus on one specific anime series where subtitle files (SRT) are available.
- The video file sizes should be limited to 500MB for processing efficiency in the MVP.
- The extracted frames will be stored on the server filesystem, and further storage optimizations (like CDN integration) can be added in later versions.