إنشاء فيديوهات باستخدام Veo 3.1 في Gemini API

للتعرّف على ميزة "فهم الفيديو"، يُرجى الاطّلاع على دليل فهم الفيديو.

Veo 3.1 هو نموذج لإنشاء فيديوهات مدتها 8 ثوانٍ (بدقة 720p أو 1080p أو 4k) مع صوت يتم إنشاؤه بشكل مدمج. يمكنك الوصول إلى هذا النموذج آليًا باستخدام Gemini API. لمزيد من المعلومات حول خيارات نماذج Veo المتاحة، يُرجى الاطّلاع على قسم إصدارات النماذج.

يتفوّق Veo 3.1 في مجموعة كبيرة من الأساليب المرئية والسينمائية، ويقدّم عدة إمكانات جديدة:

  • الفيديوهات العمودية: اختَر بين الفيديوهات الأفقية (16:9) والعمودية (9:16).
  • إضافة مدة إلى الفيديو: تتيح إضافة مدة إلى الفيديوهات التي تم إنشاؤها سابقًا باستخدام Veo.
  • إنشاء فيديو محدّد الإطار: يمكنك إنشاء فيديو من خلال تحديد الإطارَين الأول والأخير.
  • تحديد المسار الإبداعي استنادًا إلى الصور: استخدِموا ما يصل إلى ثلاث صور مرجعية لتحديد محتوى الفيديو الذي تريدون إنشاؤه.

لمزيد من المعلومات حول كتابة طلبات نصية فعالة لإنشاء الفيديوهات، يُرجى الاطّلاع على دليل طلبات Veo.

إنشاء فيديو من نص

توضّح الأمثلة التالية كيف يمكنك إنشاء فيديو يتضمّن حوارًا أو مشاهد سينمائية واقعية أو رسومًا متحركة إبداعية:

الحوار والمؤثرات الصوتية

Python

import time
from google import genai
from google.genai import types

client = genai.Client()

prompt = """A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'"""

operation = client.models.generate_videos(
    model="veo-3.1-generate-preview",
    prompt=prompt,
)

# Poll the operation status until the video is ready.
while not operation.done:
    print("Waiting for video generation to complete...")
    time.sleep(10)
    operation = client.operations.get(operation)

# Download the generated video.
generated_video = operation.response.generated_videos[0]
client.files.download(file=generated_video.video)
generated_video.video.save("dialogue_example.mp4")
print("Generated video saved to dialogue_example.mp4")

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const prompt = `A close up of two people staring at a cryptic drawing on a wall, torchlight flickering.
A man murmurs, 'This must be it. That's the secret code.' The woman looks at him and whispering excitedly, 'What did you find?'`;

let operation = await ai.models.generateVideos({
    model: "veo-3.1-generate-preview",
    prompt: prompt,
});

// Poll the operation status until the video is ready.
while (!operation.done) {
    console.log("Waiting for video generation to complete...")
    await new Promise((resolve) => setTimeout(resolve, 10000));
    operation = await ai.operations.getVideosOperation({
        operation: operation,
    });
}

// Download the generated video.
ai.files.download({
    file: operation.response.generatedVideos[0].video,
    downloadPath: "dialogue_example.mp4",
});
console.log(`Generated video saved to dialogue_example.mp4`);

Go

package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil