Use this skill for generative video editing, text-to-video, image-referenced video generation, and first-frame-to-video transition animations using the official google-genai SDK. Includes workflows for pre-processing/optimizing high-resolution or long source videos with ffmpeg.
This skill uses the Gemini Omni Flash model (gemini-omni-flash-preview) to perform text to video generation, image to video generation and video editing.
[!WARNING]
Important Regional Restrictions: Uploading videos to use for video edits is NOT available in the EEA, Switzerland, the United Kingdom, and some US states. If a video-to-video edit completes quickly with empty outputs (total_output_tokens: 0or no video content), check the current availability documentation and API error; empty output alone does not identify the cause.
These scripts upload media and prompts to Google and can incur API charges. Confirm the selected media, remote processing and batch size are within the user request before calling. Use GEMINI_API_KEY from the environment; avoid command-line keys in shell history. Work from an isolated project directory; choose new output paths because existing files are refused. Inspect generated media and report missing or partial output honestly. Never infer a regional restriction solely from empty output; inspect API errors and current official availability. Model access, SDK version requirements, limits and pricing must be checked against official documentation before use; this static bundle does not establish them.
scripts/video/generate_video.py or scripts/upload_file.py).--aspect-ratio (e.g. 16:9, 9:16) and --duration (any integer between 3 and 10 seconds, e.g. 3, 5, 10).media/). Report back the completed media path to the user.gemini-omni-flash-preview) are handled via the Interactions API.interactions.create input parts array.google-genai): Requires google-genai >= 2.10.0 (Python) to support the new interactions client attribute. Install or upgrade using:```bash
pip install -U google-genai
```
google-genai SDK types and methods).prep_video.py, inspect_video.py, and generate_video.py (when stripping audio via --strip-audio) require ffmpeg and ffprobe binaries installed and available in your system PATH.Use the following Python scripts to upload media with the Files API, prepare input videos with ffmpeg, and generate video outputs using the Interactions API.
ACTIVE. If uploading a video larger than 25MB, it prints an informative warning/tip highlighting that Gemini Omni Flash is optimized for editing 10s videos at 720p/24fps, and recommends pre-processing with prep_video.py first to speed up the upload.```bash
python3 scripts/upload_file.py path/to/image.png
```
```bash
python3 scripts/video/generatevideo.py "A close-up of a cat drinking tea" --output media/cattea.mp4
```
```bash
python3 scripts/video/generate_video.py "The waves crash against the shore." --image reference.png --output media/waves.mp4
```
Provide exactly two images as keyframes to generate a transition video between them:
```bash
python3 scripts/video/generate_video.py "A smooth timelapse from sunrise to sunset" --image start.png --image end.png --output media/interpolation.mp4
```
```bash
python3 scripts/video/generatevideo.py "Transform the style to Japanese anime" --video input.mp4 --output media/animestyle.mp4
```
```bash
python3 scripts/video/generatevideo.py "Transform the style to Japanese anime" --video input.mp4 --strip-audio --output media/animestylenewaudio.mp4
```
Edit a prior video generation without re-uploading assets by passing the interaction ID:
```bash
python3 scripts/video/generatevideo.py "Change the setting to a snowy winter wonderland." --previous-interaction-id "abc123xyz..." --output media/winterwonderland.mp4
```
```bash
python3 scripts/video/generate_video.py --prompts-file prompts.txt --concurrency 3
```
```bash
python3 scripts/video/generate_video.py --batch jobs.json --concurrency 3
```
Example jobs.json:
```json
[
{
"prompt": "Transform the style to Japanese anime.",
"video": "input.mp4",
"output": "media/anime_style.mp4",
"strip_audio": false,
"aspect_ratio": "16:9"
},
{
"prompt": "A smooth timelapse from sunrise to sunset.",
"image": ["start.png", "end.png"],
"output": "media/interpolation.mp4"
}
]
```
ffprobe) to check its duration, resolution, frame rate (FPS), audio stream presence, and format details.```bash
python3 scripts/video/inspect_video.py media/output.mp4
```
```bash
python3 scripts/video/inspect_video.py media/output.mp4 --json
```
ffprobe raw JSON dump:```bash
python3 scripts/video/inspect_video.py media/output.mp4 --raw
```
```bash
python3 scripts/video/prep_video.py path/to/source.mp4
```
or explicitly specify the start and duration:
```bash
python3 scripts/video/prep_video.py path/to/source.mp4 --start 0 --duration 10
```
```bash
python3 scripts/video/prep_video.py path/to/source.mp4 --start last
```
```bash
python3 scripts/video/prep_video.py path/to/source.mp4 --start 00:03 --output media/custom.mp4
```
```bash
python3 scripts/video/prep_video.py path/to/source.mp4 --fps 30 --resolution 1920x1080
```
```bash
python3 scripts/video/prepvideo.py path/to/source.mp4 --strip-audio --output media/videowithnoaudio.mp4
```
You can use tags in your prompt to make it clear whether each uploaded media is an initial frame or a reference.
For simple cases where image roles are clear from the prompt, you can bind images to roles directly:
<FIRST_FRAME>: Use the image as the starting frame of the video, for example: <FIRST_FRAME> a woman is walking<IMAGE_REF_N>: Use the image as a reference, for example: in the style of <IMAGE_REF_0> a woman <IMAGE_REF_1> is walking (combines style reference from the first image and subject reference from the second image). Image references start from 0.An example with 6 reference images:
[0-3s] A studio fashion sequence. Starting with woman <IMAGE_REF_0>, she is holding <IMAGE_REF_1>
[3-6s] Then we see the man <IMAGE_REF_2> holding <IMAGE_REF_3>
[6-10s] And finally another woman <IMAGE_REF_4> who is holding <IMAGE_REF_5> while walking.
For more complex cases with multiple images and multiple roles, you can use explicit prefix tags paired with natural language instruction suffixes.
[# Sources <FIRST_FRAME>@Image1] will use the first image as the starting frame.[# References <IMAGE_REF_0>@Image1] will use the first image as a reference.[# References <IMAGE_REF_1>@Image2] will use the second image as a reference.[# References <IMAGE_REF_0>@Image1 <IMAGE_REF_1>@Image2] will use both images as references.[# Sources <FIRST_FRAME>@Image1] [# References <IMAGE_REF_0>@Image2] will use the first image as the starting frame and the second image as a reference."Use the given image as the starting frame.""Use the given image(s) as references for video generation. The images should not be used as literal initial frames."```none
[# Sources
```
When editing a source video that contains audio, you must choose between keeping the original audio or regenerating all audio from scratch.
--strip-audio (or -a) when pre-processing with scripts/video/prep_video.py or executing scripts/video/generate_video.py.By default Gemini Omni Flash will try to create a video with a few different shots. It'll attempt to craft an interesting narrative based on the prompt.
If you need the output video to contain a single scene, you must prompt for that:
For example:
Continuous, unbroken handheld shot of a fluffy tabby cat sitting on a sunny windowsill, looking out into a leafy garden. The cat's tail twitches slowly, and its ears rotate slightly toward ambient noises. Sunbeams illuminate dust motes in the air. Sound design: Gentle breeze, distant bird chirps, quiet mechanical purring. No dialogue.
If generations contain things you don't want, you can include simple negatives to avoid them:
Simple prompts work best for editing. Overly descriptive prompts can lead to unintended changes.
For example:
When editing a specific aspect of the video, it can help to include: "Keep everything else the same".
By default the model will try to generate an appropriate audio track for a video. This might not always be what you want. You can use your prompt to describe the type of audio you want. This is especially important if you want music in your video:
You can prompt for things to happen at specific times in the video, there is no precise syntax needed and you can use natural language. This is especially useful in creating your own scene cuts, rhythm or rapid fire sequences.
Simple examples:
You can also use a timecode syntax:
[0-3s] A person is walking
[3-6s] They stop and turn around
[6-10s] They start running
Rather than specifying everything directly in a prompt, you can ask the model to pay attention to certain things. You can give Gemini Omni Flash these sorts of prompts verbatim:
Unlike previous video models, text in Gemini Omni Flash videos works really well. You can include decent amounts of text in your video and it will be rendered in a way that is correct and readable. If there will be naturally occurring text in your video, even in background elements, it can help to define what it should say.
For example: