feat: add /render/mp4 endpoint with FFmpeg encoding

- Add MP4Request type with fps param
- Render frames in parallel, encode via ffmpeg
- Add ffmpeg to Docker image
This commit is contained in:
devilreef 2026-01-23 01:11:53 +06:00
parent 6345eb9821
commit ce511e1a85
6 changed files with 220 additions and 0 deletions

View file

@ -150,6 +150,43 @@ const OpenAPISpec = `{
}
}
}
},
"/render/mp4": {
"post": {
"summary": "Render character as MP4 video",
"description": "Renders a character as an MP4 video rotating 360 degrees.",
"operationId": "renderMP4",
"tags": ["Render"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MP4Request"
}
}
}
},
"responses": {
"200": {
"description": "MP4 video",
"content": {
"video/mp4": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
}
},
"components": {
@ -204,6 +241,18 @@ const OpenAPISpec = `{
"dithering": {"type": "boolean", "default": true, "description": "Enable Floyd-Steinberg dithering (disable for faster rendering)"}
}
},
"MP4Request": {
"type": "object",
"required": ["character"],
"properties": {
"character": {"$ref": "#/components/schemas/CharacterConfig"},
"background": {"type": "string", "default": "#FFFFFF", "description": "Hex color background"},
"frames": {"type": "integer", "default": 36, "description": "Number of frames (36 = 10° per frame)"},
"width": {"type": "integer", "default": 512, "description": "Video width in pixels"},
"height": {"type": "integer", "default": 512, "description": "Video height in pixels"},
"fps": {"type": "integer", "default": 12, "description": "Frames per second"}
}
},
"ErrorResponse": {
"type": "object",
"properties": {