This commit is contained in:
Concept Agent
2026-05-15 18:02:38 +02:00
parent 72016728e2
commit 307e452251
175 changed files with 9316 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
"""Generate shot-02 replacement: kid runs in with muddy shoes, focus on feet and mud tracks."""
import os, sys, time, subprocess
try:
from google import genai
from google.genai import types
except ImportError:
os.system(f"{sys.executable} -m pip install google-genai --quiet")
from google import genai
from google.genai import types
API_KEY = os.environ.get("GEMINI_API_KEY", "AIzaSyB_1p8KvaT_rdNJGPs8HKk8bKsvUlcL6Kg")
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
VID_DIR = os.path.join(BASE_DIR, "assets", "videos", "hero", "clips")
REEL_OUT = os.path.join(BASE_DIR, "assets", "videos", "hero", "hero-reel.mp4")
client = genai.Client(api_key=API_KEY)
PROMPTS = [
(
"Slow cinematic shot at floor level, looking across a beige residential carpet. "
"A child's feet in muddy sneakers run into frame from the front door and across the carpet, "
"leaving clear muddy footprints with each step. Then adult feet in boots walk in behind, "
"adding more dirt and mud tracks. Camera stays low, focused on the feet and the mud on the carpet. "
"Warm indoor light. Photorealistic, slow motion."
),
(
"Low cinematic camera angle at carpet level inside a home entryway. "
"A child runs in wearing muddy shoes, close-up on their feet stomping mud into the beige carpet. "
"Adult legs follow behind, tracking in more dirt. "
"The carpet shows fresh mud and dirty footprints after each step. "
"Camera stays at floor level throughout. Warm natural light. Slow motion. Photorealistic."
),
]
MODEL = "veo-3.1-generate-preview"
out_path = os.path.join(VID_DIR, "shot-02-pan-to-stains.mp4")
def poll(op, timeout=600):
elapsed = 0
while not op.done:
if elapsed >= timeout:
return None
print(f" Waiting... ({elapsed}s)")
time.sleep(15)
elapsed += 15
op = client.operations.get(op)
return op
saved = False
for i, prompt in enumerate(PROMPTS):
print(f"\n[VID] shot-02 attempt {i+1}...")
try:
op = client.models.generate_videos(
model=MODEL,
prompt=prompt,
config=types.GenerateVideosConfig(
aspect_ratio="16:9", resolution="720p",
duration_seconds=6, number_of_videos=1,
),
)
op = poll(op)
if op and op.response and op.response.generated_videos:
vid = op.response.generated_videos[0].video
video_bytes = client.files.download(file=vid)
if video_bytes:
with open(out_path, "wb") as f:
f.write(video_bytes)
print(f" Saved ({os.path.getsize(out_path)//1024}KB)")
saved = True
break
else:
print(f" No video returned, trying next prompt...")
except Exception as e:
print(f" Error: {e}")
if not saved:
print("All attempts failed — original shot-02 kept.")
else:
ORDER = [
"shot-01-door-opens-trimmed", "shot-02-pan-to-stains", "shot-03-stain-closeup",
"shot-04-extraction-carpet", "shot-05-extraction-couch", "shot-06-extraction-stairs",
"shot-07-office-entryway", "shot-08-showroom", "shot-09-technician-unloading",
]
missing = [n for n in ORDER if not os.path.exists(os.path.join(VID_DIR, f"{n}.mp4"))]
if missing:
print(f"Skipping reconcat — missing: {missing}")
else:
concat_file = os.path.join(VID_DIR, "concat.txt")
with open(concat_file, "w") as f:
for name in ORDER:
f.write(f"file '{os.path.join(VID_DIR, name)}.mp4'\n")
result = subprocess.run(
["ffmpeg", "-y", "-f", "concat", "-safe", "0", "-i", concat_file,
"-c:v", "libx264", "-crf", "22", "-preset", "fast", "-movflags", "+faststart", REEL_OUT],
capture_output=True, text=True
)
if result.returncode == 0:
print(f" Reel saved ({os.path.getsize(REEL_OUT)//1024}KB)")
else:
print(f" ffmpeg error: {result.stderr[-300:]}")
print("\nDone.")