需求:用ffmpeg裁切视频指定坐标。
实现逻辑:
- 1. 前后端分离
- 2. 前端用React技术栈,后端用FastAPI
- 3. 用户上传视频可以预览,并且可以用自定义选择框
- 4. 用鼠标拖拉可以选择指定要裁切的框,点击确定生成指定裁切后的视频
This application allows users to upload videos, preview them, select a specific region using a draggable selection box, and crop the video using FFmpeg.
- Upload and preview videos
- Interactive crop selection with draggable handles
- Server-side video cropping using FFmpeg
- Download cropped videos
- Frontend: React, Material-UI
- Backend: FastAPI (Python)
- Video Processing: FFmpeg
- Python 3.8+ (for FastAPI backend)
- Node.js and npm (for React frontend)
- FFmpeg installed on the server
-
Navigate to the server directory:
cd server -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Run the server:
python run.py
The server will start at http://localhost:8000
-
Navigate to the client directory:
cd client -
Install dependencies:
npm install -
Start the development server:
npm start
The frontend will be available at http://localhost:3000
- Upload a video file by dragging and dropping or using the file browser
- Once the video is uploaded, it will be displayed with a crop selection box
- Drag the box to move it, or drag the handles to resize it
- Click "Crop Video" to process the video
- The cropped video will be displayed for preview
- Download the cropped video or process another one
- client/: React frontend application
- server/: FastAPI backend application
- app/: Main application directory
- routers/: API routes
- static/: Uploaded and processed videos
- requirements.txt: Python dependencies
- app/: Main application directory

