This utility splits a video into fixed-length segments, applies an FFmpeg video filter to each segment in parallel using Python's multiprocessing, and then merges the processed segments back together.
python ffmpeg_parallel_render.py input.mp4 -d 10 -f "format=gray" -w 4 -o output.mp4
The script measures sequential processing time (Before) and parallel processing time (After) and prints a speedup value.
Start the API server:
python app.py
The server runs on http://localhost:5000.
POST /api/render - Submit a video for processing
- Request: multipart form data with
fileand optional parametersfile: video file (required)filter: FFmpeg filter string (default: "format=gray")segment_duration: seconds per segment (default: 10)workers: number of parallel workers (default: cpu_count-1)
- Response:
{ "task_id": "...", "status": "queued", "message": "..." }
GET /api/status/<task_id> - Check processing status
- Response:
{ "task_id": "...", "status": "...", "sequential_time": ..., "parallel_time": ..., "speedup": ..., "analytics": {...} }
GET /api/analytics/<task_id> - Get detailed analytics report (Before vs After timing, speedup, efficiency, time breakdown)
- Response: Comprehensive analytics with before/after comparison
GET /api/download/<task_id> - Download processed video (when completed)
DELETE /api/task/<task_id> - Cancel a task
GET /api/tasks - List all tasks
GET /api/health - Health check
The API tracks comprehensive timing metrics:
- Before/After Comparison - Sequential vs Parallel processing times
- Speedup Metrics - How many times faster parallel processing is
- Efficiency Percentage - How well parallelism is being utilized
- Time Breakdown - Split, process, and merge times
- Segment Details - Per-segment processing metrics
See ANALYTICS.md for detailed documentation.
Use the analytics viewer to display results in a formatted table:
python analytics_viewer.py <task_id>
- ffmpeg and ffprobe must be installed and on your PATH.
- Python 3.7+