Grok Imagine Video Edit (xAI)
Changing an MP4 Without Re-rendering the World
- frames
- fps
- audio
- video
- video_path
- prompt
- info
Why you'd reach for it
The headline move in video this year was editing, not generating - same reason Kontext reshaped image work: reshooting a whole clip to change one detail is the expensive way to do it. This node takes an existing MP4 and a sentence, and gives you the clip back with that one thing changed. The rest is preserved. "Give the woman a silver necklace." Done.
The workflow that makes it click is chained: make a clip with Grok Imagine Video, dislike the wardrobe, and instead of paying for a fresh generation you pipe video_path straight into this node and edit it. It's a second pass, not a second shoot.
Be clear about what it is though: this is prompt-level editing, not regional V2V. There's no mask input, no per-frame control. If you want to repaint one region across every frame of a clip, that's a local workflow, and people ask for exactly that and don't find it here.
Inputs
video_path is the required one - either the video_path output of a Grok video node or a path you type in. The hard limit is 8.7 seconds, max, and the accepted codecs are H.264, H.265 and AV1. Over-length files fail at the API, so check before you queue:
ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 myclip.mp4
There's also video_url, an optional alternative for a public https URL of an MP4, used only when video_path is empty. Handy when the file already lives somewhere on the internet and you'd rather not re-upload it.
prompt describes the change and nothing else - don't re-describe the whole scene. model defaults to grok-imagine-video (1.0), which is the one xAI documents for editing; the 1.5 ID is in the dropdown too, but 1.0 is what the author's tooltip points you at. seed is the usual cache-breaker: not sent, not reproducible, and a fixed value with unchanged settings means a cached run that costs nothing.
The output keeps the input's duration and aspect ratio, capped at 720p - so an 8-second edit comes back as an 8-second 720p clip, no re-framing to argue about.
Outputs, uploads and the rest
The output set is identical to the other video nodes: frames, fps, audio, video (native VIDEO object), video_path, prompt, info. video_path goes to Grok Video Save; frames feeds anything IMAGE-shaped - an upscaler, a frame grab, VHS-style nodes; audio is a real AUDIO dict, and info reports the model, duration, the moderation flag and the billed cost.
One mechanical detail worth knowing: your local MP4 is uploaded inline as base64, not handed over as a URL. That means upload time scales with file size, which is another reason the 8.7-second cap is a blessing - trim first, edit second. extract_frames and extract_audio default on; both are media decoding done locally, so switch off whichever you don't need and save yourself the RAM. show_preview plays the finished clip with sound inside the node. The download lands in your temp folder (%TEMP%\grok_imagine) unless you set download_folder, and the save node moves it out of there.
Install
ComfyUI Manager, search Grok Imagine. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Slartibart23/comfyui-grok-imagine-video
..\..\python_embeded\python.exe -m pip install -r comfyui-grok-imagine-video\requirements.txt
Restart ComfyUI and press Ctrl+F5 once in the browser - that's what loads the in-node preview script. The dependencies are light (requests, numpy, Pillow, imageio, imageio-ffmpeg), with ffmpeg coming from imageio-ffmpeg unless you already have one on PATH. The API key comes from the api_key widget, then XAI_API_KEY, then grok_api_key.txt in the ComfyUI root, the portable root or the pack folder. Use the file or the env var; the widget value travels inside any workflow you share.
Where people get burned
The 8.7-second cap is the one that wastes your time - an over-long input comes back as an API error, not a cropped edit. Impatient polling: poll_timeout_seconds is 900 by default, and while edits are faster than a 15-second 1080p generation they still take minutes at times; raise it rather than re-queuing and paying twice. Editing something the API won't touch - filters apply here exactly as they do on generation, and info shows the respect_moderation flag when a result comes back oddly unchanged. And if you're on a 2.x install that predates these nodes, the whole video/save group needs deleting and re-adding once to pick up the current widgets.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | Local .mp4 to edit (H.264/H.265/AV1), max 8.7 seconds. Connect the video_path output of a Grok video node or type a path. The file is uploaded inline (base64). | |
| prompt | STRING | What to change, e.g. 'give the woman a silver necklace'. The rest of the video is preserved. | |
| model | COMBO | grok-imagine-video | Video editing is documented for grok-imagine-video (1.0). Output keeps the input's duration and aspect ratio, capped at 720p. |
| seed | INT | 00–18446744073709550000 | Cache-breaker only (not sent). |
| video_urlopt | STRING | Alternative to video_path: a PUBLIC https URL of an .mp4 (max 8.7 s). Used only when video_path is empty. | |
| extract_framesopt | BOOLEAN | true | Decode the MP4 into an IMAGE batch on the 'frames' output. Turn off to save RAM/time when you only need the file, the VIDEO object or the audio. |
| extract_audioopt | BOOLEAN | true | Decode the video's audio track to the 'audio' output (AUDIO). Needs ffmpeg (bundled with imageio-ffmpeg). Off = silent placeholder. |
| custom_modelopt | STRING | Type any model ID here to override the dropdown (e.g. a brand-new release). Leave empty to use the dropdown. See console.x.ai or GET /v1/models for valid IDs. | |
| api_keyopt | STRING | Your xAI API key. NOT recommended here — it is saved inside exported workflows. Prefer the XAI_API_KEY environment variable or the key file. | |
| api_key_fileopt | STRING | grok_api_key.txt | Text file containing only the key. Searched in the ComfyUI root, the portable root and this pack's folder (or give an absolute path). The same file serves the Prompt Forge pack. |
| base_urlopt | STRING | https://api.x.ai/v1 | API base URL. Leave at https://api.x.ai/v1 unless you use a proxy. |
| poll_interval_secondsopt | INT | 52–60 | Seconds between status checks while the video renders. |
| poll_timeout_secondsopt | INT | 90060–7200 | Maximum seconds to wait for the video job. 15-second 1080p clips can take several minutes — raise this if jobs time out. |
| download_folderopt | STRING | Where the finished MP4 is downloaded BEFORE you save it. Empty = the Windows temp folder (<Temp>\grok_imagine). Grok Video Save MOVES the file from here to your final folder, so nothing piles up. Never the ComfyUI output folder. | |
| show_previewopt | BOOLEAN | true | Show the finished video with sound directly in this node after the run - handy for checking before you save. No file is written for this. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| frames | IMAGE | All decoded frames as an IMAGE batch (empty 64x64 placeholder if extract_frames is off). |
| fps | FLOAT | Frame rate of the MP4 as reported by the decoder - connect to Save/Combine nodes. |
| audio | AUDIO | Decoded soundtrack as AUDIO (silent placeholder if the file has no audio or extract_audio is off). Works with Save Video / Video Combine audio inputs. |
| video | VIDEO | Native ComfyUI VIDEO object (file-backed) for Save Video, Preview Video, Get Video Components. None on very old ComfyUI builds. |
| video_path | STRING | Path of the downloaded MP4 in the temp folder - connect to Grok Video Save, which moves it to your folder without re-encoding, or to Video Edit / Extend. |
| prompt | STRING | The prompt exactly as sent, for Save nodes (prompt_text) or captions. |
| info | STRING | Facts about the job: model used, duration, moderation flag, request_id, billed cost. |