MCPcopy
hub / github.com/htdt/godogen / cmd_video

Function cmd_video

asset-gen/tools/asset_gen.py:210–243  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

208
209
210def cmd_video(args):
211 cost = args.duration * VIDEO_COST_PER_SEC
212 output = Path(args.output)
213 output.parent.mkdir(parents=True, exist_ok=True)
214
215 image_path = Path(args.image)
216 if not image_path.exists():
217 result_json(False, error=f"Reference image not found: {image_path}")
218 sys.exit(1)
219
220 print(f"Generating {args.duration}s video ({args.resolution})...", file=sys.stderr)
221 image_url = _image_data_uri(image_path)
222
223 try:
224 client = xai_sdk.Client()
225 resp = client.video.generate(
226 prompt=args.prompt,
227 model=VIDEO_MODEL,
228 image_url=image_url,
229 duration=args.duration,
230 aspect_ratio="1:1",
231 resolution=args.resolution,
232 )
233 # Download MP4
234 print(" Downloading video...", file=sys.stderr)
235 dl = requests.get(resp.url, timeout=120)
236 dl.raise_for_status()
237 output.write_bytes(dl.content)
238 except Exception as e:
239 result_json(False, error=str(e))
240 sys.exit(1)
241
242 print(f"Saved: {output}", file=sys.stderr)
243 result_json(True, path=str(output), cost_cents=cost)
244
245
246def _sidecar_path(output: Path) -> Path:

Callers

nothing calls this directly

Calls 2

result_jsonFunction · 0.85
_image_data_uriFunction · 0.85

Tested by

no test coverage detected