auto-sync: 2026-04-30 01:10:01

This commit is contained in:
Stream
2026-04-30 01:10:01 +03:00
parent 1768596750
commit 7f3283cff5

View File

@@ -12,8 +12,9 @@ from dotenv import load_dotenv
load_dotenv(os.path.expanduser("~/.openclaw/.env"))
FFMPEG = os.environ.get("FFMPEG_BIN", os.path.expanduser("~/bin/ffmpeg-7.0.2-amd64-static/ffmpeg"))
FFPROBE = os.environ.get("FFPROBE_BIN", os.path.expanduser("~/bin/ffmpeg-7.0.2-amd64-static/ffprobe"))
import shutil
FFMPEG = os.environ.get("FFMPEG_BIN") or shutil.which("ffmpeg") or os.path.expanduser("~/bin/ffmpeg")
FFPROBE = os.environ.get("FFPROBE_BIN") or shutil.which("ffprobe") or FFMPEG # fallback to ffmpeg
def search_pexels(query: str, per_page: int = 3) -> list[dict]:
@@ -74,13 +75,17 @@ def download_url(url: str, dest: str) -> str:
def get_duration(path: str) -> float:
"""Длительность видео в секундах через ffprobe."""
cmd = [
FFPROBE, "-v", "quiet", "-show_entries", "format=duration",
"-of", "csv=p=0", path
]
out = subprocess.check_output(cmd, text=True).strip()
return float(out)
"""Длительность видео в секундах через ffmpeg -i."""
result = subprocess.run(
[FFMPEG, "-i", path],
capture_output=True, text=True
)
import re
m = re.search(r"Duration: (\d+):(\d+):([\d.]+)", result.stderr)
if m:
h, mn, s = m.groups()
return int(h) * 3600 + int(mn) * 60 + float(s)
raise RuntimeError(f"Не удалось получить длительность: {path}")
def create_black_video(duration: float, dest: str, width: int = 1280, height: int = 720):