前置条件
开始之前,你需要:
- FFHub 账号(点击注册)
- 从控制台获取的 API Key
FFmpeg API 快速开始
1. 创建转码任务
提交 FFmpeg 命令来转码视频:
curl -X POST https://api.ffhub.io/v1/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"command": "ffmpeg -i https://storage.ffhub.io/Sample_Video_File_100MB.mp4 -c:v libx264 -preset fast output.mp3"
}'
2. 查询任务状态
轮询任务接口检查进度:
curl https://api.ffhub.io/v1/tasks/{task_id} \
-H "Authorization: Bearer YOUR_API_KEY"
3. 获取结果
任务完成后,你将获得输出文件的 URL:
{
"task_id": "abc123",
"status": "completed",
"progress": 100,
"outputs": [
{
"filename": "output.mp4",
"url": "https://storage.ffhub.io/outputs/abc123/output.mp4",
"size": 1234567
}
]
}
Storage API 快速开始
上传文件
curl -X POST https://files-api.ffhub.io/api/upload/file \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/image.png"
curl -X POST https://files-api.ffhub.io/api/upload/base64 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"data": "data:image/png;base64,iVBORw0KGgo..."}'
curl -X POST https://files-api.ffhub.io/api/upload/url \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/image.png"}'
响应格式
所有上传方式返回相同的响应格式:
{
"url": "https://storage.ffhub.io/uploads/user123/abc123.png",
"cn_url": "https://beijing-user-upload-tmp.tos-cn-beijing.volces.com/uploads/user123/abc123.png",
"key": "uploads/user123/abc123.png",
"size": 12345,
"content_type": "image/png",
"expires_at": "2024-01-17T00:00:00.000Z"
}
文件会在 1 天后过期。如需永久保存,请在过期前下载。
下一步