Media
将MP4视频转换为GIF格式,支持30秒限制和自定义质量设置
用三种语言从你的代码中调用此工具。
# 1) Request a presigned URL → returns { uploadUrl, storageKey }
curl -X POST 'https://api.elysiatools.com/api/upload/presign/mp4-to-gif' \
-H 'Content-Type: application/json' \
-d '{"filename":"videoFile.ext","contentType":"application/octet-stream","size":12345}'
# 2) PUT the file bytes directly to the presigned uploadUrl
curl -X PUT '<presigned uploadUrl>' \
--data-binary @/path/to/file.ext
# 3) Call the tool, passing the returned storageKey for each file field
curl -X POST 'https://api.elysiatools.com/zh/api/tools/mp4-to-gif' \
-F 'videoFile=uploads/2026/01/01/your-tool-1700000000000-abc123.ext' \
-F 'width=0' \
-F 'height=0' \
-F 'fps=10' \
-F 'startTime=0' \
-F 'duration=30' \
-F 'quality=80' \
-F 'colors=256' \
-F 'optimize=true' \
-F 'dithering=true'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/mp4-to-gif| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| videoFile | file需先上传 | 是 | — |
| width | number | 否 | 目标宽度(像素,最大2048) |
| height | number | 否 | 目标高度(像素,最大2048) |
| fps | number | 否 | 动画帧率 (1-30 fps) |
| startTime | number | 否 | 从此时间开始转换(秒) |
| duration | number | 否 | GIF最大30秒 |
| quality | number | 否 | 更高质量 = 更大文件 |
| colors | number | 否 | 更多颜色 = 更好质量但文件更大 |
| optimize | checkbox | 否 | 使用优化的调色板获得更好的压缩 |
| dithering | checkbox | 否 | 应用抖动获得更平滑的颜色过渡 |
文件结果
{
"filePath": "/public/processing/randomid.ext",
"fileName": "output.ext",
"contentType": "application/octet-stream",
"size": 1024,
"metadata": {
"key": "value"
},
"error": "Error message (optional)",
"message": "Notification message (optional)"
}将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-mp4-to-gif": {
"name": "mp4-to-gif",
"description": "将MP4视频转换为GIF格式,支持30秒限制和自定义质量设置",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=mp4-to-gif",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "mp4-to-gif",
"arguments": {
"videoFile": "https://example.com/file.ext",
"width": 0,
"height": 0,
"fps": 10,
"startTime": 0,
"duration": 30,
"quality": 80,
"colors": 256,
"optimize": true,
"dithering": true
}
}
}有问题或反馈?请联系 [email protected]