Text and Image to Video Skill
Create a video generation task based on provided text content and images. The task is submitted immediately; the system will automatically poll the task status and retrieve the video link.
Usage Scenarios
✅ Recommended for these situations:
- - "Turn this image into a video as I describe"
- "Please help me make a video from this image according to my requirements"
- "Use this image to generate a video as requested"
- "Generate a video based on text and an image"
Not for These Scenarios
❌ Do not use for the following cases:
- - The user asks for video editing, trimming, or adding special effects → Please use a video editing tool
- The user requests screen recording or capture → Please use a screen recording tool
- The user only wants to check the progress of an existing video task → Please guide them to check in the related file or system
Prerequisites
CODEBLOCK0
INLINECODE0 is the required environment variable for the remote video service client.
Overall Workflow (Agent Guide)
- 1. Extract the full text (
TEXT) and image address or path (IMAGE) from the user's message. - Use the
video-create subcommand to create the task, read the stdout JSON output, and extract the task_id. - Clearly inform the user of the
task_id in the chat by outputting "Video generation task has been created, task ID: task_id. I will keep checking the task status and inform you when the video link is ready." - Use the
video-wait subcommand with --task-id to poll the task until completion. Task status equal to 2 means success. - Extract the
video_url from the video-wait command's stdout. - Clearly inform the user of the final video link
video_url in the chat. If timeout occurs, report it as well.
Python Client (Step-by-Step Example & Chat Output)
Step 1: Create the Video Task and Show the task_id in Chat
- 1. Obtain the desired video text from the user and store it in
TEXT; get the image address and store it in IMAGE.
- If the text contains double quotes
", be sure to escape them (e.g., replace
" with
\") to prevent command parsing errors.
- 2. Run the following command (invoked by the agent tool;
{baseDir} will be replaced with the skill directory):
CODEBLOCK1
- 3. Read the command's standard output (stdout), which is JSON, for example:
CODEBLOCK2
- 4. Parse the
task_id from the JSON (e.g. "abc-123"), and inform the user in the chat:
- Output: "Video generation task has been created, task ID:
task_id. I will keep checking the task status and inform you when the video link is ready."
Step 2: Poll Task Status and Output the Final video_url in Chat
- 1. Use the
task_id obtained in the previous step.
- 2. Execute this command (poll every 10 seconds, wait up to 600 seconds; if timeout, please try again later):
CODEBLOCK3
- 3. Read the standard output. On success, the JSON output looks like:
CODEBLOCK4
- 4. Parse the key fields from the output:
- - Task status (e.g.,
task_status: 2), where status 2 means success - Video link (e.g.,
video_url: "https://example.com/path/to/video.mp4")
- 5. Recommended chat reply flow:
- - Summarize the key info in plain language, for example:
> "Task complete ✅
> task_id: abc-123
> Video link: https://example.com/path/to/video.mp4"
- 6. If the result shows task failure or timeout (e.g.,
success is false, video_url is empty, or error is timeout):
- - Explain the failure reason (include error info if possible), and inform the user they can retry later or check possible issues like input or quota.
Script Output Requirements
- Parse stdout JSON.
- Clearly inform the user of both the task ID and video link in the chat.
文本与图片生成视频技能
根据提供的文本内容和图片创建视频生成任务。任务将立即提交;系统会自动轮询任务状态并获取视频链接。
适用场景
✅ 推荐用于以下情况:
- - 将这张图片按照我的描述转换成视频
- 请根据我的要求用这张图片帮我制作一个视频
- 使用这张图片按要求生成视频
- 基于文本和图片生成视频
不适用场景
❌ 请勿用于以下情况:
- - 用户要求视频编辑、裁剪或添加特效 → 请使用视频编辑工具
- 用户请求屏幕录制或截屏 → 请使用屏幕录制工具
- 用户只想查看现有视频任务的进度 → 请引导其在相关文件或系统中查看
前置条件
bash
export MAGICAPIKEY=your-key
MAGICAPIKEY 是远程视频服务客户端所需的环境变量。
整体工作流程(智能体指南)
- 1. 从用户消息中提取完整文本(TEXT)和图片地址或路径(IMAGE)。
- 使用 video-create 子命令创建任务,读取标准输出的 JSON 内容,提取 taskid。
- 在对话中明确告知用户 taskid,输出 视频生成任务已创建,任务ID:taskid。我将持续检查任务状态,并在视频链接就绪时通知您。
- 使用 video-wait 子命令配合 --task-id 参数轮询任务直至完成。任务状态等于 2 表示成功。
- 从 video-wait 命令的标准输出中提取 videourl。
- 在对话中明确告知用户最终视频链接 video_url。如果发生超时,也需告知用户。
Python 客户端(分步示例与对话输出)
第一步:创建视频任务并在对话中显示 task_id
- 1. 获取用户期望的视频文本并存入 TEXT;获取图片地址并存入 IMAGE。
- 如果文本中包含双引号 ,务必进行转义(例如将 替换为 \),以防止命令解析错误。
- 2. 运行以下命令(由智能体工具调用;{baseDir} 将被替换为技能目录):
bash
python3 {baseDir}/scripts/mediagenclient.py video-create \
--text TEXT --image IMAGE
- 3. 读取命令的标准输出(stdout),其为 JSON 格式,例如:
json
{
biz_code: 10000,
msg: Success,
data: {
task_id: 2032443088023777280
},
trace_id: 664c6e22-1edd-11f1-bf4c-8262dce7d13f
}
- 4. 从 JSON 中解析出 task_id(例如 abc-123),并在对话中告知用户:
- 输出:视频生成任务已创建,任务ID:task_id。我将持续检查任务状态,并在视频链接就绪时通知您。
第二步:轮询任务状态并在对话中输出最终 video_url
- 1. 使用上一步获取的 task_id。
- 2. 执行以下命令(每 10 秒轮询一次,最长等待 600 秒;若超时,请稍后重试):
bash
python3 {baseDir}/scripts/mediagenclient.py video-wait --task-id YOURTASKID --poll 10 --timeout 600
- 3. 读取标准输出。成功时,JSON 输出如下:
json
{
biz_code: 10000,
msg: Success,
data: {
task_id: 1234567890,
task_status: 2,
video_url: https://www.magiclight.com/examplevideo.mp4
},
trace_id: c89aeca8-1edd-11f1-bf4c-8262dce7d13f
}
- 4. 从输出中解析关键字段:
- - 任务状态(例如 taskstatus: 2),状态 2 表示成功
- 视频链接(例如 videourl: https://example.com/path/to/video.mp4)
- 5. 推荐的对话回复流程:
> 任务完成 ✅
> 任务ID:abc-123
> 视频链接:https://example.com/path/to/video.mp4
- 6. 如果结果显示任务失败或超时(例如 success 为 false、video_url 为空或 error 为 timeout):
- - 说明失败原因(尽可能包含错误信息),并告知用户可以稍后重试或检查输入、配额等可能的问题。
脚本输出要求
- 解析标准输出的 JSON。
- 在对话中明确告知用户任务 ID 和视频链接。