api-config.json 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. {
  2. "name": "quickly-video-create",
  3. "displayName": "一键成片 - 创建生成任务",
  4. "description": "调用 Quickly 开放平台,基于图片/视频素材一键生成短视频。传入素材URL列表和关键词,返回 task_id,通过 quickly-video-query 轮询获取视频下载链接。",
  5. "category": "video-creation",
  6. "version": "1.0.0",
  7. "endpoint": {
  8. "method": "POST",
  9. "url": "https://server.fmode.cn/api/functions/cut/onemerge",
  10. "headers": {
  11. "Content-Type": "application/json"
  12. }
  13. },
  14. "parameters": {
  15. "type": "object",
  16. "required": ["material_list", "tags", "proportion", "video_duration", "pre_id"],
  17. "properties": {
  18. "material_list": {
  19. "type": "array",
  20. "description": "素材列表,每项包含 type(pic|video)和 value(公网可访问URL)。图片支持 jpg/jpeg/png/gif,视频支持 mp4/webm。webp/非ASCII URL 需先转换,见 materialFormatRules。",
  21. "items": {
  22. "type": "object",
  23. "required": ["type", "value"],
  24. "properties": {
  25. "type": {
  26. "type": "string",
  27. "enum": ["pic", "video"],
  28. "description": "素材类型:pic=图片,video=视频"
  29. },
  30. "value": {
  31. "type": "string",
  32. "description": "素材的公网可访问URL,必须为纯ASCII字符,格式为 jpg/jpeg/png/gif(图片)或 mp4/webm(视频)"
  33. }
  34. }
  35. },
  36. "minItems": 1,
  37. "maxItems": 50,
  38. "recommended": "建议 5~15 个素材,效果最佳"
  39. },
  40. "tags": {
  41. "type": "string",
  42. "description": "逗号分隔的关键词,描述视频主题内容,由调用方根据业务场景自行提供",
  43. "example": "推拉门,极简风格,铝合金,隔音"
  44. },
  45. "proportion": {
  46. "type": "string",
  47. "enum": ["9:16", "3:4", "1:1"],
  48. "description": "视频比例:9:16=竖屏(1080×1920,抖音/快手主流),3:4=竖屏宽(900×1200),1:1=方形(1080×1080)",
  49. "default": "9:16"
  50. },
  51. "video_duration": {
  52. "type": "object",
  53. "description": "视频时长范围(秒)",
  54. "required": ["min", "max"],
  55. "properties": {
  56. "min": {
  57. "type": "integer",
  58. "enum": [5, 10, 15, 20, 25],
  59. "description": "最短时长(秒)",
  60. "default": 10
  61. },
  62. "max": {
  63. "type": "integer",
  64. "enum": [10, 15, 20, 25, 30],
  65. "description": "最长时长(秒)",
  66. "default": 20
  67. }
  68. }
  69. },
  70. "pre_id": {
  71. "type": "string",
  72. "description": "预定视频ID,纯数字格式,多个视频用逗号分隔(如 '1711234567890' 或 '1711234567890,1711234567891')。使用 Date.now() 生成基础ID,每个视频递增1。",
  73. "example": "1711234567890"
  74. },
  75. "compose_number": {
  76. "type": "integer",
  77. "description": "生成视频数量,1~50",
  78. "default": 1,
  79. "minimum": 1,
  80. "maximum": 50
  81. },
  82. "ai_voice": {
  83. "type": "integer",
  84. "enum": [0, 1],
  85. "description": "是否开启 AI 配音(0=关闭,1=开启)",
  86. "default": 1
  87. },
  88. "ai_bgm": {
  89. "type": "integer",
  90. "enum": [0, 1],
  91. "description": "是否开启 AI 背景音乐(0=关闭,1=开启)",
  92. "default": 1
  93. },
  94. "ai_flower": {
  95. "type": "integer",
  96. "enum": [0, 1],
  97. "description": "是否开启 AI 特效转场(0=关闭,1=开启)",
  98. "default": 1
  99. },
  100. "ai_subtitle": {
  101. "type": "integer",
  102. "enum": [0, 1],
  103. "description": "是否开启 AI 字幕(0=关闭,1=开启)",
  104. "default": 0
  105. },
  106. "original_voice": {
  107. "type": "integer",
  108. "enum": [0, 1],
  109. "description": "是否保留视频素材原始音频(0=关闭,1=开启)",
  110. "default": 0
  111. }
  112. }
  113. },
  114. "materialFormatRules": {
  115. "supportedImageFormats": ["jpg", "jpeg", "png", "gif"],
  116. "supportedVideoFormats": ["mp4", "webm"],
  117. "unsupportedImageFormats": ["webp", "heic", "bmp", "tiff"],
  118. "unsupportedVideoFormats": ["mov", "avi", "mkv", "flv", "wmv"],
  119. "conversionRules": [
  120. {
  121. "trigger": "图片格式为 webp 或不在支持列表中",
  122. "solution": "通过浏览器 Canvas API 加载图片 → 导出为 JPEG (quality=0.9) → 上传至公网可访问的 CDN → 使用返回的新 URL",
  123. "uploadPrefix": "ai-video/converted/"
  124. },
  125. {
  126. "trigger": "URL 含非ASCII字符(中文文件名、特殊符号等)",
  127. "solution": "decodeURIComponent(url) 检测到非ASCII字符后,重新下载并上传 CDN 获取干净 URL",
  128. "uploadPrefix": "ai-video/image/"
  129. },
  130. {
  131. "trigger": "本地上传文件",
  132. "solution": "直接上传 CDN,图片前缀 ai-video/image/,视频前缀 ai-video/video/"
  133. },
  134. {
  135. "trigger": "视频格式不支持(mov/avi等)",
  136. "solution": "跳过该素材,提示用户转换为 mp4 后重新上传"
  137. }
  138. ],
  139. "cdnUpload": {
  140. "note": "所有素材需上传至国内可达的公网 CDN(如七牛、阿里云OSS),确保返回纯 ASCII URL。Quickly 服务器在国内,无法访问境外CDN,否则任务静默失败。"
  141. }
  142. },
  143. "requestTransform": {
  144. "description": "通过 server.fmode.cn 中转:将业务参数包装为 relay 请求,中转服务负责签名并调用 Quickly API",
  145. "body": {
  146. "action": "relay",
  147. "relayData": "JSON.stringify({ apiPath: '/v2/video/vlog/create', apiBody: {业务参数}, appKey: '{{appKey}}', timestamp: '{{timestamp}}', sign: 'MD5(timestamp#appSecret)' })"
  148. },
  149. "signGeneration": {
  150. "step1": "timestamp = Date.now().toString()",
  151. "step2": "signStr = timestamp + '#' + appSecret // 直接使用原始字符串,不做base64解码",
  152. "step3": "sign = MD5(signStr).toLowerCase() [32位小写]"
  153. }
  154. },
  155. "response": {
  156. "type": "object",
  157. "description": "Quickly API 返回结果",
  158. "properties": {
  159. "code": {
  160. "type": "integer",
  161. "description": "0 或 200 表示成功,其他值表示错误"
  162. },
  163. "message": {
  164. "type": "string",
  165. "description": "响应描述信息"
  166. },
  167. "data": {
  168. "type": "object",
  169. "properties": {
  170. "task_id": {
  171. "type": "string",
  172. "description": "任务ID,传入 quickly-video-query 进行轮询查询"
  173. }
  174. }
  175. },
  176. "request_id": {
  177. "type": "string",
  178. "description": "请求唯一ID,用于联系 Quickly 客服排查问题"
  179. }
  180. }
  181. },
  182. "pollingConfig": {
  183. "description": "获取 task_id 后调用 quickly-video-query 轮询视频生成结果",
  184. "interval": 15000,
  185. "maxAttempts": 40
  186. },
  187. "usageExamples": [
  188. {
  189. "name": "图片素材生成竖屏短视频(9:16)",
  190. "description": "传入图片和视频素材,生成9:16竖屏短视频,适合抖音/快手发布",
  191. "input": {
  192. "material_list": [
  193. { "type": "pic", "value": "https://cdn.example.com/images/img1.jpg" },
  194. { "type": "pic", "value": "https://cdn.example.com/images/img2.jpg" },
  195. { "type": "pic", "value": "https://cdn.example.com/images/img3.jpg" },
  196. { "type": "video", "value": "https://cdn.example.com/videos/clip1.mp4" }
  197. ],
  198. "tags": "推拉门,极简风格,铝合金,隔音,全屋定制",
  199. "proportion": "9:16",
  200. "video_duration": { "min": 10, "max": 20 },
  201. "pre_id": "1711234567890",
  202. "compose_number": 3,
  203. "ai_voice": 1,
  204. "ai_bgm": 1,
  205. "ai_flower": 1,
  206. "ai_subtitle": 0
  207. },
  208. "expectedOutput": {
  209. "code": 0,
  210. "data": { "task_id": "987654321" }
  211. }
  212. },
  213. {
  214. "name": "图片素材生成方形视频(1:1)",
  215. "description": "生成1:1方形视频,适合朋友圈/公众号发布",
  216. "input": {
  217. "material_list": [
  218. { "type": "pic", "value": "https://cdn.example.com/images/img1.jpg" },
  219. { "type": "pic", "value": "https://cdn.example.com/images/img2.jpg" }
  220. ],
  221. "tags": "全屋定制,整体家装,收纳设计",
  222. "proportion": "1:1",
  223. "video_duration": { "min": 10, "max": 15 },
  224. "pre_id": "1711234567900",
  225. "compose_number": 1,
  226. "ai_voice": 1,
  227. "ai_bgm": 1,
  228. "ai_subtitle": 1
  229. }
  230. }
  231. ],
  232. "errorHandling": {
  233. "apiErrors": [
  234. { "code": "非0/200", "action": "抛出错误,提示用户检查素材格式和网络" },
  235. { "code": "素材URL不可访问", "action": "Quickly API 会在回调中返回 error_msg,前端需处理 success=false 的回调" }
  236. ],
  237. "materialErrors": [
  238. { "condition": "所有素材转换失败", "action": "中止生成,提示'没有可用的素材,请添加 JPG/PNG 图片或 MP4 视频后重试'" },
  239. { "condition": "有效素材列表为空", "action": "提前退出,不调用API" }
  240. ]
  241. },
  242. "timeout": 30000,
  243. "retry": {
  244. "maxAttempts": 2,
  245. "delay": 2000,
  246. "backoffMultiplier": 2
  247. }
  248. }