Gjeneroni dhe modifikoni video me Gemini Omni Flash

Gemini Omni Flash ( gemini-omni-1.1-flash ) është një model multimodal me performancë të lartë i projektuar për gjenerim videoje me shpejtësi të lartë, montim dhe kontroll kinematografik. Gemini Omni është ndërtuar mbi aftësitë kryesore të mëposhtme që e dallojnë atë nga modelet e mëparshme të videos:

  • Multimodaliteti nativ: përpunon tekstin, imazhin, audion dhe videon njëkohësisht, duke ju dhënë rezultate më kohezive, konsistente dhe të kontrollueshme.
  • Redaktimi bisedor: i aktivizuar nga Interactions API , ju lejon të përsosni dhe redaktoni videot tuaja në mënyrë iterative përmes bisedës në gjuhën natyrore. Përshkruani se çfarë doni të ndryshoni dhe modeli zbaton redaktimin duke ruajtur pjesët e videos që dëshironi të ruani.
  • Njohuri për botën: Gemini Omni kombinon një kuptim të fizikës me njohuritë e Gemini për historinë, shkencën dhe kontekstin kulturor, duke kapërcyer hendekun nga fotorealizmi te rrëfimi kuptimplotë.

Gjenerimi i tekstit në video

Gjenero një video nga një kërkesë me tekst. Modeli gjeneron një video me audio bazuar në përshkrimin tënd me tekst. Shkruaj kërkesa me detaje si përshkrimi i skenës, lëvizja e kamerës, ndriçimi dhe atmosfera për rezultatet më të mira.

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A marble rolling fast on a chain reaction style track, continuous smooth shot."
)
with open("marble.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A marble rolling fast on a chain reaction style track, continuous smooth shot.',
});

if (interaction.output_video?.data) {
  fs.writeFileSync('marble.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("A marble rolling fast on a chain reaction style track, continuous smooth shot."))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("marble.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A marble rolling fast on a chain reaction style track, continuous smooth shot."
}'

Skema e përgjigjes REST

Fusha e lehtësisë interaction.output_video është vetëm për SDK . Merrni rezultatin e videos nga vargu i steps kur përdorni direkt API-n REST.

Struktura e papërpunuar e REST JSON:

{
  "steps": [
    { "type": "user_input", "content": [{"type": "text", "text": "..."}] },
    { "type": "thought", "content": [{"text": "...", "type": "thought"}] },
    {
      "type": "model_output",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "data": "AAAAIGZ0eXBpc29t..." // Base64 encoded video data
        }
      ]
    }
  ],
  "id": "v1_...",
  "status": "completed",
  "model": "gemini-omni-1.1-flash",
  "object": "interaction"
}

Raporti i aspektit të kontrollit

Cakto aspect_ratio"9:16" për të krijuar video portreti. Parazgjedhja është horizonti (16:9).

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A futuristic city with neon lights and flying cars, cyberpunk style",
    response_format={
        "type": "video",  # optional
        "aspect_ratio": "9:16"  # Supported values: "9:16", "16:9"
    }
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A futuristic city with neon lights and flying cars, cyberpunk style',
  response_format: {
    type: 'video', // optional
    aspect_ratio: '9:16' // Supported values: '9:16', '16:9'
  },
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseFormat;
import com.google.genai.gaos.models.interactions.VideoResponseFormat;
import com.google.genai.gaos.models.interactions.VideoResponseFormatAspectRatio;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

Client client = new Client();

VideoResponseFormat videoFormat =
    VideoResponseFormat.builder()
        .aspectRatio(VideoResponseFormatAspectRatio.of("9:16"))
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("A futuristic city with neon lights and flying cars, cyberpunk style"))
        .responseFormat(CreateModelInteractionResponseFormat.of(ResponseFormat.of(videoFormat)))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("example.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A futuristic city with neon lights and flying cars, cyberpunk style",
 "response_format": {
   "type": "video",
   "aspect_ratio": "9:16"
 }
}'

Rezolucioni i daljes

Kontrolloni rezolucionin e daljes së videos së gjeneruar duke përdorur parametrin e resolutionresponse_format . Rezolucioni i parazgjedhur është 720p.

Vlerë Përshkrimi
360p Rezolucioni i daljes 360p
720p Rezolucioni i daljes 720p (parazgjedhur)
1080p Dalje 1080p (e përmirësuar)
4k Prodhim 4K (i përmirësuar)

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A drone shot of a mountain landscape at sunrise.",
    response_format={
        "type": "video",
        "resolution": "1080p",
    },
)
with open("hires.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A drone shot of a mountain landscape at sunrise.',
  response_format: {
    type: 'video',
    resolution: '1080p',
  },
});

if (interaction.output_video?.data) {
  fs.writeFileSync('hires.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.Resolution;
import com.google.genai.gaos.models.interactions.ResponseFormat;
import com.google.genai.gaos.models.interactions.VideoResponseFormat;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

Client client = new Client();

VideoResponseFormat videoFormat =
    VideoResponseFormat.builder()
        .resolution(Resolution.of("1080p"))
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("A drone shot of a mountain landscape at sunrise."))
        .responseFormat(CreateModelInteractionResponseFormat.of(ResponseFormat.of(videoFormat)))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("hires.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A drone shot of a mountain landscape at sunrise.",
 "response_format": {
   "type": "video",
   "resolution": "1080p"
 }
}'

Gjenerimi i imazhit në video

Mund të jepni një imazh referimi me kërkesën tuaj me tekst. Në varësi të kërkesës suaj, modeli do të vendosë se si ta përdorë imazhin. Kjo është e dobishme për t'i dhënë jetë pamjeve, ilustrimeve ose fotografive të produkteve.

Shembulli i mëposhtëm tregon se si të përdoret imazhi referues i një vizatimi të një peshku që hidhet nga uji:

Vizatim i një peshku që kërcen nga uji

Me nxitjen e mëposhtme:

turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video

Për të gjeneruar një video realiste të vizatimit.

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
        {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
    ],
)
with open("clownfish.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: base64Image, mime_type: 'image/jpeg' },
    { type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('clownfish.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

byte[] imageBytes = Files.readAllBytes(Paths.get("first_frame.png"));
String base64Image = Base64.getEncoder().encodeToString(imageBytes);

Content imageContent =
    ImageContent.builder()
        .data(base64Image)
        .mimeType(ImageContentMimeType.IMAGE_PNG)
        .build();

Content textContent =
    TextContent.builder()
        .text("A mythical dragon perched on a craggy peak slowly unfolds its wings and lets out a roar.")
        .build();

List<Content> contents = Arrays.asList(imageContent, textContent);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("dragon.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$BASE64_IMAGE"'", "mime_type": "image/jpeg"},
   {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
 ]
}'

Interpolimi i kuadrit të parë dhe të fundit

Gemini Omni Flash mbështet interpolimin e videos, duke ju lejuar të gjeneroni një video që kalon pa probleme midis një imazhi fillestar (korniza e parë) dhe një imazhi përfundimtar (korniza e fundit).

Jepni dy imazhe në listën input dhe përshkruani tranzicionin e dëshiruar në kërkesën tuaj. Modeli do ta animojë skenën nga kuadri i parë në kuadrin përfundimtar.

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": first_frame_b64, "mime_type": "image/jpeg"},
        {"type": "image", "data": last_frame_b64, "mime_type": "image/jpeg"},
        {"type": "text", "text": "A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky."}
    ],
)
with open("interpolation.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: firstFrameB64, mime_type: 'image/jpeg' },
    { type: 'image', data: lastFrameB64, mime_type: 'image/jpeg' },
    { type: 'text', text: 'A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky.' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('interpolation.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

String firstFrameB64 = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("first_frame.jpg")));
String lastFrameB64 = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("last_frame.jpg")));

Content firstFrame =
    ImageContent.builder()
        .data(firstFrameB64)
        .mimeType(ImageContentMimeType.IMAGE_JPEG)
        .build();

Content lastFrame =
    ImageContent.builder()
        .data(lastFrameB64)
        .mimeType(ImageContentMimeType.IMAGE_JPEG)
        .build();

Content prompt =
    TextContent.builder()
        .text("A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky.")
        .build();

List<Content> contents = Arrays.asList(firstFrame, lastFrame, prompt);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("interpolation.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$FIRST_FRAME_B64"'", "mime_type": "image/jpeg"},
   {"type": "image", "data": "'"$LAST_FRAME_B64"'", "mime_type": "image/jpeg"},
   {"type": "text", "text": "A smooth cinematic transition from a lush green forest at sunrise to a snowy forest under a starry night sky."}
 ]
}'

Referenca e subjektit

Mund të gjeneroni një video që përfshin subjekte specifike të ofruara si imazhe referimi. Për shembull, kodi i mëposhtëm tregon se si të ofroni 2 imazhe të një maceje dhe një fije për të gjeneruar një video të maces duke luajtur me fijen.

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": cat_b64, "mime_type": "image/png"},
        {"type": "image", "data": yarn_b64, "mime_type": "image/png"},
        {"type": "text", "text": "A cat playfully batting at a ball of yarn."}
    ],
)
with open("cat.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: catData, mime_type: 'image/png' },
    { type: 'image', data: yarnData, mime_type: 'image/png' },
    { type: 'text', text: 'A cat playfully batting at a ball of yarn.' }
  ]
});

if (interaction.output_video?.data) {
  fs.writeFileSync('cat.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

byte[] imageBytes = Files.readAllBytes(Paths.get("reference.png"));
String base64Image = Base64.getEncoder().encodeToString(imageBytes);

Content imageContent =
    ImageContent.builder()
        .data(base64Image)
        .mimeType(ImageContentMimeType.IMAGE_PNG)
        .build();

Content textContent =
    TextContent.builder()
        .text("A cute small creature like the one in <image_1> is running in a sunny park chasing a butterfly.")
        .build();

List<Content> contents = Arrays.asList(imageContent, textContent);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("creature.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "image", "data": "'"$CAT_B64"'", "mime_type": "image/png"},
   {"type": "image", "data": "'"$YARN_B64"'", "mime_type": "image/png"},
   {"type": "text", "text": "A cat playfully batting at a ball of yarn."}
 ]
}'

Parametri i Detyrave

Përdorni parametrin taskvideo_config për të specifikuar në mënyrë të qartë sjelljen e synuar, për shembull, nëse dëshironi që modeli të gjenerojë një video nga një imazh, mund ta vendosni parametrin në image_to_video . Nëse kjo nuk është vendosur, modeli do të nxjerrë përfundimin se çfarë dëshironi nga kërkesa.

Vlerat e lejuara janë si më poshtë:

  • text_to_video
  • image_to_video
  • reference_to_video
  • edit
  • extend

Shembulli i mëposhtëm tregon se si ta caktoni këtë për shembullin e kthimit të imazhit në video të treguar më parë.

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "image", "data": base64_image, "mime_type": "image/jpeg"},
        {"type": "text", "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"}
    ],
    generation_config={
      "video_config": {
        "task": "image_to_video",
      }
    },
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from "@google/genai";
import * as fs from 'fs';
const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'image', data: base64Image, mime_type: 'image/jpeg' },
    { type: 'text', text: 'turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video' }
  ],
  generationConfig: {
    videoConfig: {
      task: 'image_to_video',
    }
  }
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.Task;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.VideoConfig;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

byte[] imageBytes = Files.readAllBytes(Paths.get("reference.png"));
String base64Image = Base64.getEncoder().encodeToString(imageBytes);

Content imageContent =
    ImageContent.builder()
        .data(base64Image)
        .mimeType(ImageContentMimeType.IMAGE_PNG)
        .build();

Content textContent =
    TextContent.builder()
        .text("A fast red sports car drives down an empty desert highway at dusk.")
        .build();

List<Content> contents = Arrays.asList(imageContent, textContent);

GenerationConfig generationConfig =
    GenerationConfig.builder()
        .videoConfig(VideoConfig.builder().task(Task.IMAGE_TO_VIDEO).build())
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .generationConfig(generationConfig)
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("task_output.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-1.1-flash",
    "input": [
      {
        "type": "image",
        "data": "'"$BASE64_IMAGE"'",
        "mime_type": "image/jpeg"
      },
      {
        "type": "text",
        "text": "turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video"
      }
    ],
    "generation_config": {
      "video_config": {
        "task": "image_to_video"
      }
    }
  }'

Redaktim videoje me status të lartë

Gjeneroni një video dhe modifikojeni atë në mënyrë iterative duke përdorur udhëzime pasuese. Çdo raund ndërtohet mbi rezultatin e mëparshëm. Modeli mban mend kontekstin e videos, duke zbatuar ndryshimet tuaja ndërsa ruan elementët që nuk i keni përmendur. Përdorni previous_interaction_id për të ndjekur historikun e bisedës dhe gjendjen e videos së gjeneruar pa e ngarkuar përsëri videon e mëparshme.

Shembulli i mëposhtëm tregon se si të gjeneroni një video së pari dhe pastaj ta modifikoni atë:

Python

import base64
from google import genai

client = genai.Client()

# Turn 1: Generate initial video
res1 = client.interactions.create(model="gemini-omni-1.1-flash", input="A woman playing violin outdoors.")

# Turn 2: Edit the previous video
res2 = client.interactions.create(
    model="gemini-omni-1.1-flash",
    previous_interaction_id=res1.id,
    input="Make the violin invisible."
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(res2.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Turn 1: Generate initial video
const res1 = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A woman playing violin outdoors.',
});

// Turn 2: Edit the previous video
const res2 = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  previous_interaction_id: res1.id,
  input: 'Make the violin invisible.',
});

if (res2.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(res2.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

Client client = new Client();

// Turn 1: Generate initial video
CreateModelInteraction turn1Params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("A person in a red jacket standing in a snowy landscape."))
        .build();

Interaction turn1 =
    client.interactions.create(CreateInteractionRequestBody.of(turn1Params)).interaction().get();

// Turn 2: Edit the previous video using previousInteractionId
CreateModelInteraction turn2Params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("Change the jacket to bright yellow."))
        .previousInteractionId(turn1.id().get())
        .build();

Interaction turn2 =
    client.interactions.create(CreateInteractionRequestBody.of(turn2Params)).interaction().get();

if (turn2.outputVideo().isPresent() && turn2.outputVideo().get().data().isPresent()) {
    byte[] videoBytes = Base64.getDecoder().decode(turn2.outputVideo().get().data().get());
    Files.write(Paths.get("edited.mp4"), videoBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "previous_interaction_id": "'"$PREVIOUS_ID"'",
 "input": "Make the violin invisible."
}'

Shembull i një videoje fillestare:

Shembull i një videoje të modifikuar:

Çdo kthesë në bisedë prodhon një video të re. Modeli e kupton kontekstin nga kthesat e mëparshme, duke ju lejuar të bëni ndryshime graduale si rregullimi i ndriçimit dhe ndërrimi i sfondeve, pa e ripërshkruar të gjithë skenën.

Redaktoni videot tuaja

Ngarkoni videot tuaja duke përdorur API-n e Skedarëve për t'i modifikuar ato me Gemini Omni Flash.

Shembulli i mëposhtëm tregon se si të modifikoni videon origjinale të mëposhtme:

Python

import time
import base64
from google import genai

client = genai.Client()

# Upload video using the file API
video_file = client.files.upload(file="Video.mp4")

while video_file.state == "PROCESSING":
    print('Waiting for video to be processed.')
    time.sleep(10)
    video_file = client.files.get(name=video_file.name)

if video_file.state == "FAILED":
  raise ValueError(video_file.state)
print(f'Video processing complete: ' + video_file.uri)

# Edit your video
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "text", "text": "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material"}
    ],
)
with open("example.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload video using the file API
let videoFile = await ai.files.upload({
  file: 'Video.mp4',
});

while (videoFile.state === 'PROCESSING') {
  console.log('Waiting for video to be processed.');
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
}

if (videoFile.state === 'FAILED') {
  throw new Error(videoFile.state);
}
console.log('Video processing complete: ' + videoFile.uri);

// Edit your video
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'text', text: "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material" }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.VideoContent;
import com.google.genai.gaos.models.interactions.VideoContentMimeType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

byte[] videoBytes = Files.readAllBytes(Paths.get("my_video.mp4"));
String base64Video = Base64.getEncoder().encodeToString(videoBytes);

Content videoContent =
    VideoContent.builder()
        .data(base64Video)
        .mimeType(VideoContentMimeType.VIDEO_MP4)
        .build();

Content textContent =
    TextContent.builder()
        .text("Make the violin completely invisible while keeping the musician playing normally in the air.")
        .build();

List<Content> contents = Arrays.asList(videoContent, textContent);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] editedBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("edited_invisible_violin.mp4"), editedBytes);
}

PUSHTIM

#!/bin/bash
VIDEO_B64=$(encode_file "$VIDEO_FILE")

curl -sS -w "\n[HTTP %{http_code}]\n" "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d @- <<EOF > video_editing_response.json
{
  "model": "gemini-omni-1.1-flash",
  "input": [
    {
      "type": "user_input",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "data": "$VIDEO_B64"
        },
        {
          "type": "text",
          "text": "When the person touches the mirror, make the mirror ripple beautifully like liquid, and the person's arm turns into reflective mirror material"
        }
      ]
    }
  ],
  "response_format": { "type": "video" }
}
EOF

Shembull i një videoje të modifikuar:

Duke marrë videot me një URI

Përdorni parametrin delivery="uri"response_format për të gjetur videot e gjeneruara që janë më të mëdha se 4MB. Kjo kthen një URI të strehuar nga Google që mund ta anketoni derisa videoja të jetë ACTIVE para shkarkimit.

Python

import time
from google import genai

client = genai.Client()

# 1. Request video via URI delivery
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input="A beautiful sunset.",
    response_format={"type": "video", "delivery": "uri"}
)

# 2. Extract file name and poll for ACTIVE state
video_output = interaction.output_video
file_name = video_output.uri.split("/")[-1] # Extract ID

print("Waiting for video processing...")
while True:
    f_info = client.files.get(name=f"files/{file_name}")
    if f_info.state.name == "ACTIVE":
        break
    elif f_info.state.name == "FAILED":
        raise RuntimeError("Generation failed.")
    time.sleep(5)

# 3. Download the final video
client.files.download(file=video_output.uri, destination="output.mp4")

JavaScript

import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({});

// 1. Request video via URI delivery
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: 'A beautiful sunset.',
  response_format: { type: 'video', delivery: 'uri' },
});

// 2. Extract file name and poll for ACTIVE state
const videoOutput = interaction.output_video;
const fileId = videoOutput.uri.match(/files\/([a-zA-Z0-9]+)/)[1];
const name = `files/${fileId}`;

console.log("Waiting for video processing...");
while (true) {
  const fInfo = await ai.files.get({ name });
  if (fInfo.state.name === 'ACTIVE') break;
  if (fInfo.state.name === 'FAILED') throw new Error("Generation failed.");
  await new Promise(r => setTimeout(r, 5000));
}

// 3. Download the final video
await ai.files.download({
  file: videoOutput,
  downloadPath: 'output.mp4',
});
console.log("💾 Saved video to output.mp4");

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseFormat;
import com.google.genai.gaos.models.interactions.VideoResponseFormat;
import com.google.genai.gaos.models.interactions.VideoResponseFormatDelivery;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

// 1. Request video via URI delivery
VideoResponseFormat videoFormat =
    VideoResponseFormat.builder()
        .delivery(VideoResponseFormatDelivery.URI)
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.of("A camera flies over a misty redwood forest at sunrise."))
        .responseFormat(CreateModelInteractionResponseFormat.of(ResponseFormat.of(videoFormat)))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

// 2. Extract file URI
interaction.outputVideo().flatMap(v -> v.uri()).ifPresent(uri -> {
    System.out.println("Video URI: " + uri);
});

PUSHTIM

#!/bin/bash

# 1. Initial request to generate the video
RESPONSE=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "model": "gemini-omni-1.1-flash",
 "input": "A beautiful sunset over a calm ocean.",
 "response_format": {"type": "video", "delivery": "uri"}
}')

# Extract FILE_ID from the URI (e.g., "files/abc-123" -> "abc-123")
FILE_URI=$(echo $RESPONSE | jq -r '.output_video.uri')
FILE_ID=$(echo $FILE_URI | cut -d'/' -f2)

echo "Video requested (ID: $FILE_ID). Waiting for processing..."

# 2. Polling loop
while true; do
 # Get current file status
 STATUS_JSON=$(curl -s -X GET "https://generativelanguage.googleapis.com/v1beta/files/$FILE_ID?key=$API_KEY")
 STATE=$(echo $STATUS_JSON | jq -r '.state')

 if [ "$STATE" == "ACTIVE" ]; then
   echo "Processing complete! Downloading..."
   break
 elif [ "$STATE" == "FAILED" ]; then
   echo "Error: Generation failed."
   exit 1
 else
   echo "Current state: $STATE... (waiting 5s)"
   sleep 5
 fi
done

# 3. Final download
curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/files/$FILE_ID:download?alt=media&key=$API_KEY" \
--output "output.mp4"

echo "Done! Video saved to output.mp4"

Struktura e papërpunuar REST JSON (URI):

{
  "steps": [
    { "type": "user_input", "content": [{"type": "text", "text": "..."}] },
    { "type": "thought", "content": [{"text": "...", "type": "thought"}] },
    {
      "type": "model_output",
      "content": [
        {
          "type": "video",
          "mime_type": "video/mp4",
          "uri": "https://generativelanguage.googleapis.com/v1beta/files/...:download?alt=media"
        }
      ]
    }
  ],
  "id": "v1_...",
  "status": "completed",
  "model": "gemini-omni-1.1-flash",
  "object": "interaction"
}


Zgjatimi i videos

Zgjeroni një video ekzistuese duke gjeneruar një vazhdim të pandërprerë në fund të klipit. Përshkruani se si dëshironi që videoja të vazhdojë në njoftimin tuaj, për shembull "Extend this video" ose "Continue the scene: the camera pans across the mountains" . Modeli analizon videon hyrëse për të gjeneruar një vazhdim 3-10 sekondash.

Ju mund të zgjasni:

  • Videot e gjeneruara nga modeli (me shumë kthesa) : Zgjero një video të gjeneruar më parë duke iu referuar previous_interaction_id të saj.
  • Videot e ngarkuara : Jepni një skedar video të ngarkuar (nëpërmjet API-t të Skedarëve) së bashku me kërkesën tuaj të zgjerimit.

Python

import base64
from google import genai

client = genai.Client()

# Upload your video using the Files API
video_file = client.files.upload(file="my_video.mp4")

# Extend the video using prompt-based extension
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "text", "text": "Continue the scene."}
    ],
)
with open("extended.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload your video using the Files API
let videoFile = await ai.files.upload({
  file: 'my_video.mp4',
});

while (videoFile.state === 'PROCESSING') {
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
}

// Extend the video using prompt-based extension
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'text', text: 'Continue the scene.' }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('extended.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.VideoContent;
import com.google.genai.gaos.models.interactions.VideoContentMimeType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

// Load base video
byte[] videoBytes = Files.readAllBytes(Paths.get("my_video.mp4"));
String base64Video = Base64.getEncoder().encodeToString(videoBytes);

Content videoContent =
    VideoContent.builder()
        .data(base64Video)
        .mimeType(VideoContentMimeType.VIDEO_MP4)
        .build();

// Prompt describing seamless continuation
Content promptContent =
    TextContent.builder()
        .text("Continue the scene.")
        .build();

List<Content> contents = Arrays.asList(videoContent, promptContent);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] extendedBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("extended.mp4"), extendedBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY"     -H "Content-Type: application/json"     -d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "document", "uri": "'"$VIDEO_URI"'"},
   {"type": "text", "text": "Continue the scene."}
 ]
}'

Zgjerimi me media referuese

Mund të jepni imazhe referimi në vargun input së bashku me kërkesën tuaj për të futur karaktere ose elementë të rinj në videon e zgjeruar:

Python

import base64
from google import genai

client = genai.Client()

# Upload base video and reference image using the Files API
video_file = client.files.upload(file="my_video.mp4")
character_img = client.files.upload(file="character.png")

# Extend the video while introducing the reference character
interaction = client.interactions.create(
    model="gemini-omni-1.1-flash",
    input=[
        {"type": "document", "uri": video_file.uri},
        {"type": "document", "uri": character_img.uri},
        {"type": "text", "text": "Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave."}
    ],
)
with open("extended_with_character.mp4", "wb") as f:
    f.write(base64.b64decode(interaction.output_video.data))

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});

// Upload base video and reference image using the Files API
let videoFile = await ai.files.upload({ file: 'my_video.mp4' });
let characterImg = await ai.files.upload({ file: 'character.png' });

while (videoFile.state === 'PROCESSING' || characterImg.state === 'PROCESSING') {
  await new Promise(r => setTimeout(r, 10000));
  videoFile = await ai.files.get({ name: videoFile.name });
  characterImg = await ai.files.get({ name: characterImg.name });
}

// Extend the video while introducing the reference character
const interaction = await ai.interactions.create({
  model: 'gemini-omni-1.1-flash',
  input: [
    { type: 'document', uri: videoFile.uri },
    { type: 'document', uri: characterImg.uri },
    { type: 'text', text: 'Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave.' }
  ],
});

if (interaction.output_video?.data) {
  fs.writeFileSync('extended_with_character.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.VideoContent;
import com.google.genai.gaos.models.interactions.VideoContentMimeType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;

Client client = new Client();

// Load base video and reference character image
byte[] videoBytes = Files.readAllBytes(Paths.get("my_video.mp4"));
byte[] charBytes = Files.readAllBytes(Paths.get("character.png"));

Content baseVideo =
    VideoContent.builder()
        .data(Base64.getEncoder().encodeToString(videoBytes))
        .mimeType(VideoContentMimeType.VIDEO_MP4)
        .build();

Content characterImg =
    ImageContent.builder()
        .data(Base64.getEncoder().encodeToString(charBytes))
        .mimeType(ImageContentMimeType.IMAGE_PNG)
        .build();

Content prompt =
    TextContent.builder()
        .text("Extend the video: the car stops, and the traveler from <image_1> steps out and waves at the sunset.")
        .build();

List<Content> contents = Arrays.asList(baseVideo, characterImg, prompt);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-omni-1.1-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

if (interaction.outputVideo().isPresent() && interaction.outputVideo().get().data().isPresent()) {
    byte[] extendedBytes = Base64.getDecoder().decode(interaction.outputVideo().get().data().get());
    Files.write(Paths.get("extended_with_character.mp4"), extendedBytes);
}

PUSHTIM

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY"     -H "Content-Type: application/json"     -d '{
 "model": "gemini-omni-1.1-flash",
 "input": [
   {"type": "document", "uri": "'$VIDEO_URI'"},
   {"type": "document", "uri": "'$CHARACTER_IMG_URI'"},
   {"type": "text", "text": "Extend this video: have the character shown in <IMAGE_REF_0> enter the scene and wave."}
 ]
}'

Kufizimet dhe udhëzimet e zgjerimit

Mbani në mend rregullat dhe kufizimet e mëposhtme kur zgjeroni videot:

  • Dialogu i folur në videot e ngarkuara : Aktualisht, nuk mund ta zgjasni një video të ngarkuar ku dikush po flet për të shtuar dialog shtesë (mbështetet nëse personazhi mbetet i heshtur ose nëse kërkesa nuk shton dialog).
  • Zgjerim zanor me shumë kthesa : Gjenerimi i dialogut ose i të folurit mbështetet kur zgjerohen videot e gjeneruara më parë nëpërmjet funksionit me shumë kthesa ( previous_interaction_id ).
  • Vetëm fundi i klipit : Shtesa është e kufizuar në shtimin në fund të videos. Nuk mund ta paravendosësh përmbajtjen ose ta zgjasësh mesin e një klipi.
  • Kufiri i kohëzgjatjes : Videot hyrëse për zgjatjen duhet të jenë 10 sekonda ose më pak në gjatësi gjatë ngarkimit (përveç nëse përdoret modaliteti me shumë kthesa).
  • Disponueshmëria rajonale : Zgjerimi i videove të ngarkuara nuk është aktualisht i disponueshëm për përdoruesit në Zonën Ekonomike Evropiane (EEA), Zvicër dhe Mbretërinë e Bashkuar (zgjerimi i videove të gjeneruara nga modeli mbështetet në të gjitha rajonet e disponueshme).

Praktikat më të mira

  • Përdorni shpërndarjen URI për video të mëdha: Për video më të mëdha se 4MB (>720p kur është e disponueshme), përdorni delivery="uri"response_format për të shmangur kufizimet e madhësisë së ngarkesës.
  • Performancë e optimizuar: Vendosni background=false , store=false dhe stream=false për gjenerim më të shpejtë dhe sinkron të njëkohshëm. Vini re se vendosja e store=false do të thotë që videoja e gjeneruar nuk do të jetë e modifikueshme në kthesat pasuese duke përdorur previous_interaction_id .
  • Saktësi e menjëhershme: Shihni seksionin e udhëzimeve të menjëhershme për detaje.

Kufizime

  • Ngarkimi dhe redaktimi i imazheve që përmbajnë përmbajtje të mitur nuk mbështetet në Zonën Ekonomike Evropiane, Zvicër dhe Mbretërinë e Bashkuar.
  • Ngarkimi dhe redaktimi i imazheve që përmbajnë persona të caktuar të njohur nuk mbështetet.
  • Redaktimi ose zgjerimi i videove të ngarkuara nuk është aktualisht i disponueshëm për përdoruesit në Zonën Ekonomike Evropiane (EEA), Zvicër dhe Mbretërinë e Bashkuar (mbështetet redaktimi ose zgjerimi i videove të gjeneruara nga modeli).
  • Videot hyrëse për redaktim dhe zgjerim duhet të jenë 10 sekonda ose më pak gjatë ngarkimit (përveç nëse videot e zgjeruara të gjeneruara nga modeli në shumë kthesa).
  • Zgjatja e videos është e kufizuar në shtimin në fund të një videoje; vendosja para ose zgjatja e mesit të një klipi nuk mbështetet.
  • Nuk mund ta zgjasësh një video të ngarkuar ku dikush po flet për të shtuar dialog shtesë (personazhet mund të mbeten të heshtur ose mund të përdoret zgjerimi me shumë kthesa me previous_interaction_id ).
  • Redaktimi i zërit nuk mbështetet.
  • Ngarkimi i referencave audio nuk mbështetet në versionin aktual të API-t.
  • Referencat e videove funksionojnë më mirë me ngjashmëritë; çdo audio në një referencë videoje injorohet. Referencat e videove mbështesin një maksimum prej 3 klipesh, deri në 3 sekonda secili.
  • Referimi ose arsyetimi nëpër video të shumëfishta nuk mbështetet. Përpjekja për të nxitur video të shumëfishta mund të rezultojë në performancë të degraduar të modelit ose rezultate të papritura.
  • Rendimenti i parashikuar nuk mbështetet.
  • Udhëzimet e sistemit, temperatura, top_p , sekuencat e ndalimit dhe kërkesat negative nuk mbështeten (mund t'i vendosni vlerat negative në kërkesën e rregullt: p.sh., "Mos e bëj X").
  • Përdorimi i videove në YouTube si burim mediash nuk mbështetet.

Detajet teknike

  • Të gjitha videot e gjeneruara përfshijnë filigranin SynthID, i cili është i padukshëm për shikuesit, por mund të zbulohet në mënyrë programore për verifikimin e origjinës.
  • Kohët e gjenerimit të videove ndryshojnë në bazë të kohëzgjatjes, rezolucionit dhe ngarkesës aktuale të API-t. Videot më të gjata dhe me rezolucion më të lartë kërkojnë më shumë kohë për t'u gjeneruar.
  • Omni aplikon filtra sigurie përmbajtjeje si për kërkesat hyrëse ashtu edhe për videon e gjeneruar (të cilat ndryshojnë sipas rajonit). Kërkesat që shkelin politikat e përdorimit bllokohen.
  • Anglishtja (EN) mbështetet plotësisht, por gjuhët e tjera nuk janë vlerësuar, kështu që mund të funksionojnë, por rezultatet mund të ndryshojnë.

Udhëzuesi i shpejtë i Gemini Omni Flash

Ky seksion përmban këshilla dhe shembuj se si ta nxisni në mënyrë efektive Gemini Omni Flash.

Skenë e vetme

Si parazgjedhje, Omni Flash do të përpiqet të krijojë një video me disa pamje të ndryshme. Do të përpiqet të krijojë një rrëfim interesant bazuar në kërkesën.

Nëse keni nevojë që videoja dalëse të përmbajë një skenë të vetme, duhet ta kërkoni këtë:

  • Në një skenë të vetme të pandërprerë
  • Në një të shtënë të vetme të vazhdueshme
  • Pa prerje skenash

Për shembull:

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. No dialogue.

Heqja e elementëve të padëshiruar

Nëse videoja e gjeneruar përmban gjëra që nuk i dëshironi, përfshini sugjerime të thjeshta negative për t'i shmangur ato:

  • Asnjë dialog
  • Pa zbukurime
  • Pa efekte shtesë zanore

Kërkesat për redaktim

Kërkesat e thjeshta funksionojnë më mirë për redaktimin e videove. Kërkesat tepër përshkruese mund të çojnë në ndryshime të padëshiruara.

Më poshtë janë shembuj të tjerë të udhëzimeve të thjeshta për redaktim:

  • Bëjeni këtë video anime
  • Vendos një kapelë në modë këtij personi
  • Ndryshoni ndriçimin për ta bërë më dramatik
  • Ndrysho tekstin në tabelë që të thotë "Omni Flash"

Kur redaktoni një aspekt specifik të videos, përfshi "Keep everything else the same" për të ruajtur qëndrueshmërinë vizuale.

Më poshtë janë disa shembuj për të treguar se si të aplikohet kjo teknikë:

  • Shmangni: In the video of the man sitting on the sofa, please add a small black cat that runs from the right side of the screen, jumps onto his lap, and then he starts to stroke its head while looking down.
    • Thjeshtojeni: Add a cat that jumps onto his lap, he begins to pet it. Keep everything else the same.
  • Shmangni: Please remove the cell phone that the person is holding in their hand and fill in the background so it looks like they are just holding their hand empty.
    • Thjeshtojeni: Make the phone invisible. Keep everything else the same.

Duke nxitur audion

Si parazgjedhje, modeli do të përpiqet të gjenerojë një pistë audio të përshtatshme për një video. Kjo mund të mos jetë gjithmonë ajo që dëshironi. Mund ta përdorni kërkesën tuaj për të përshkruar llojin e audios që dëshironi. Kjo është veçanërisht e rëndësishme nëse dëshironi muzikë në videon tuaj:

  • Përfshi muzikë të qetë në sfond
  • Videoja ka një ritëm tekno me energji të lartë
  • Audioja është një transmetim radiofonik me zë të ulët në sfond, që luan një këngë

Ngjarjet e kohës

Mund të kërkoni që gjërat të ndodhin në momente specifike në video, nuk ka nevojë për sintaksë të saktë dhe mund të përdorni gjuhë natyrale. Kjo është veçanërisht e dobishme në krijimin e prerjeve tuaja të skenës, ritmit ose sekuencave të shpejta. Shihni më poshtë për shembuj:

  • Pas 3 sekondash, një grua hyn në skenë.
  • Në sekondat 5 fillon refreni në audion e sfondit.
  • Çdo 2 sekonda prite në një kornizë të re.
  • Në një sekuencë xhirimi të shpejtë, çdo gjysmë sekonde (12 kuadro me 24 kuadro për sekondë) ndryshojeni skenën në një vendndodhje të re.

Mund të përdorni edhe një sintaksë të kodit kohor:

[0-3s] A person is walking
[3-6s] They stop and turn around
[6-10s] They start running

Meta-nxitje

Mund t’i kërkoni Gemini Omni Flash t’i kushtojë vëmendje cilësive ose parimeve të përgjithshme të gjenerimit të videos:

  • Merrni në konsideratë mikro-detajet, shprehjen dhe kohën për të krijuar një skenë shumë të pasur, të detajuar, por krejtësisht natyrale.
  • Ji jashtëzakonisht i detajuar në përshkrimet e personazheve dhe mjediseve. Zbato parimet e dizajnit të kostumeve tek personazhet. Ji shumë specifik në lidhje me njerëzit, sendet dhe objektet në skenë.
  • Përfshini shumë detaje të përshtatshme në elementët e sfondit për ta bërë skenën të duket realiste dhe natyrale.
  • Bëni një video me ritëm të shpejtë që tregon një [thing] të rrallë të ndryshme çdo 1 sekondë, muzikë ritmike, përfshi tekst për ta etiketuar gjënë.

Teksti në video

Mund të kërkoni të përfshini tekst në videon tuaj dhe Gemini Omni do ta paraqesë në një mënyrë të saktë dhe të lexueshme. Nëse do të ketë tekst që shfaqet natyrshëm në videon tuaj, madje edhe në elementët e sfondit, mund të ndihmojë të përcaktohet se çfarë duhet të thotë.

  • Një fjalë në ekran në të njëjtën kohë: "a e dije që Omni mund ta bëjë tekstin e mrekullueshëm?" Çdo fjalë shfaqet për 1 me një stil të ndryshëm të animuar. Pa dialog.
  • Ka një tabelë rrugore që thotë: "Kjo është një gjeneratë e IA-së nga Omni", ka një vitrinë që thotë: "Gjithçka që ju nevojitet IA", ka një makinë me targë: "OMNI1.1"

Kërkesa për zgjatjen e një videoje

Me Gemini Omni 1.1 Flash mund t’i zgjasni videot me sugjerime të tilla si, "Extend this video" ose "The scene continues" . Mund t’i zgjasni videot me 10 sekonda, deri në një gjatësi totale prej 40 sekondash.

Omni krijon një zgjerim që e mban videon, lëvizjen, personazhet dhe audion koherente duke përdorur 10 sekondat e fundit të videos suaj origjinale si kontekst. Disa nga kuadrot përfundimtare në videon tuaj hyrëse do të modifikohen për ta bërë tranzicionin pa probleme.

Kur zgjeroheni, të gjitha këshillat e këtij udhëzuesi për nxitjen Omni vlejnë ende:

  • Përshkruani audion në skenën tuaj të zgjeruar, veçanërisht nëse keni nevojë ta ndryshoni: "The music continues into the chorus"
  • Përshkruani nëse skena vazhdon, ose nëse ka një prerje të xhirimit në një skenë të re (ndoshta me të njëjtët personazhe): "Show the same characters in the next scene"
  • Përfshi imazhe dhe video si referenca kur zgjeroni për të ndihmuar në ruajtjen e saktësisë së rezultateve tuaja ose për të futur personazhe të rinj: "The person shown in the reference image enters the scene" , "The dog in the reference video <VIDEO_REF_0> jumps onto the sofa"
  • Nëse përdorni pulla kohore ose një sintaksë kodi kohor, 0-të i referohen fillimit të pjesës së zgjeruar të videos. Nëse zgjerohet një video 10-sekondëshe, prerja e skenës në këtë njoftim do të ndodhë pas 12 sekondash: "After 2s cut to a new scene with the same characters"

Përdorimi i etiketave në udhëzime për të vendosur role të imazhit dhe videos

Mund të përdorni etiketa për të lidhur mediat e ngarkuara me role specifike gjenerimi. Kjo ju lejon të specifikoni nëse çdo imazh ose video është një kuadër fillestar, një kuadër përfundimtar apo një referencë.

1. Etiketa të thjeshta (të rekomanduara)

Për raste të thjeshta ku rolet e mediave janë të qarta nga kërkesa, mund t'i lidhni imazhet dhe videot drejtpërdrejt me rolet:

  • <FIRST_FRAME> : përdor imazhin si kornizë fillestare të videos, për shembull: <FIRST_FRAME> a woman is walking
  • <LAST_FRAME> : përdor imazhin si kuadrin përfundimtar të videos për të kaluar në të. Duhet të përdoret me <FIRST_FRAME> , për shembull: <FIRST_FRAME> <LAST_FRAME> a woman is walking
  • <IMAGE_REF_N> : përdor imazhin si referencë, për shembull: in the style of <IMAGE_REF_0> a woman <IMAGE_REF_1> is walking (kombinon referencën e stilit nga imazhi i parë dhe referencën e subjektit nga imazhi i dytë). Referencat e imazhit fillojnë nga 0.
  • <VIDEO_REF_N> : përdor videon si referencë për personazhin ose objektin, për shembull: the person in <VIDEO_REF_0> is playing the violin . Referencat e videos gjithashtu fillojnë nga 0.

Më poshtë është një shembull me 6 imazhe referuese:

[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.

2. Deklarimi i burimeve dhe referencave

Për raste më komplekse me hyrje të shumëfishta mediatike dhe role të shumëfishta, mund të përdorni etiketa prefiksesh eksplicite të çiftëzuara me udhëzime të gjuhës natyrore. Duhet t'i deklaroni këto burime dhe referenca në fillim të kërkesës suaj.

  • [# Sources <FIRST_FRAME>@Image1] do të përdorin imazhin e parë si kornizë fillestare.
  • [# Sources <FIRST_FRAME>@Image1 <LAST_FRAME>@Image2] do të përdorin imazhin e parë si kornizën fillestare dhe imazhin e dytë si kornizën përfundimtare.
  • [# Sources <FIRST_FRAME>@Image1 <LAST_FRAME>@Image1] do të përdorin imazhin e parë si kornizën e parë dhe si kornizën e fundit, duke krijuar një video që përsëritet përsëri.
  • [# Sources <FIRST_FRAME>@Image1] [# References <IMAGE_REF_0>@Image2] do të përdorin imazhin e parë si kornizë fillestare dhe imazhin e dytë si referencë.
  • [# Sources <VIDEO_0>@Video1] do ta përdorin videon si burimin kryesor të videos për ta modifikuar ose modifikuar.
  • [# Sources <PREVIOUS_VIDEO>@Video1] do të përdorin videon nga radha e mëparshme për të zgjeruar.
  • [# References <IMAGE_REF_0>@Image1] do të përdorin imazhin e parë si referencë.
  • [# References <IMAGE_REF_1>@Image2] do të përdorin imazhin e dytë si referencë.
  • [# References <IMAGE_REF_0>@Image1 <IMAGE_REF_1>@Image2] do të përdorin të dy imazhet si referenca.
  • [# References <VIDEO_REF_0>@Video1] do të përdorë videon e parë si referencë.
  • [# References <IMAGE_REF_0>@Image1 <VIDEO_REF_0>@Video1] do të përdorë si një imazh ashtu edhe një video si referencë.

Shtoni udhëzime udhëzuese në fund të kërkesës suaj:

  • Për një kornizë fillestare: "Use this image as the starting frame."
  • Për një video që përsëritet me anë të kuadrit fillestar dhe atij përfundimtar: "Use this image as the first frame and the last frame."
  • Për imazhet referuese: "Use the given image(s) as references for video generation. The images should not be used as literal initial frames."
  • Për videot referuese: "Use the given video(s) as references. Do not use them as a source for video editing."

Disa shembuj të kërkesave me deklarata burimi dhe reference:

Korniza fillestare e kombinuar me një imazh reference:

[# Sources <FIRST_FRAME>@Image1] [# References <IMAGE_REF_0>@Image2] a woman <IMAGE_REF_0> is walking. Use Image1 as the starting frame. Use Image2 as a reference for the video generation.

Video referimi për personazhin e kombinuar me një imazh referimi për objektin:

[# References <IMAGE_REF_0>@Image1 <VIDEO_REF_0>@Video1] The woman in <VIDEO_REF_0> is playing the violin shown in <IMAGE_REF_0>. Use Video1 as a character reference and Image1 as an object reference.

Çfarë vjen më pas