Gemini를 사용하여 로컬 동영상 파일 요약

이 샘플에서는 Gemini를 사용하여 로컬 동영상 파일을 요약하는 방법을 보여줍니다.

코드 샘플

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google import genai
from google.genai.types import HttpOptions, Part

client = genai.Client(http_options=HttpOptions(api_version="v1"))
model_id = "gemini-2.5-flash"

# Read local video file content
with open("test_data/describe_video_content.mp4", "rb") as fp:
    # Video source: https://storage.googleapis.com/cloud-samples-data/generative-ai/video/describe_video_content.mp4
    video_content = fp.read()

response = client.models.generate_content(
    model=model_id,
    contents=[
        Part.from_text(text="hello-world"),
        Part.from_bytes(data=video_content, mime_type="video/mp4"),
        "Write a short and engaging blog post based on this video.",
    ],
)

print(response.text)
# Example response:
# Okay, here's a short and engaging blog post based on the climbing video:
# **Title: Conquering the Wall: A Glimpse into the World of Indoor Climbing**
# ...

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기