-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
[[
"prompt" => $prompt,
"image" => [
"mimeType" => $mime,
"imageBytes" => base64_encode($img)
]
]]
]);
$ctx = stream_context_create([
'http' => [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
'x-goog-api-key: ' . $API_KEY,
],
'content' => $payload
]
]);
$resp = file_get_contents($BASE_URL . "/models/$model:predictLongRunning", false, $ctx);
$d = json_decode($resp, true);
if (empty($d['name'])) { var_dump($d); exit; }
$op = $d['name'];
$videoUri = null;
for ($i = 0; $i < 30; $i++) {
$ctxGet = stream_context_create([
'http' => [
'header' => ['x-goog-api-key: ' . $API_KEY]
]
]);
$opResp = file_get_contents($BASE_URL . '/' . $op, false, $ctxGet);
$opData = json_decode($opResp, true);
if (!empty($opData['done'])) {
$videoUri = $opData['response']['generateVideoResponse']['generatedSamples'][0]['video']['uri'] ?? null;
break;
}
sleep(10);
}
if (!$videoUri) { var_dump($opData ?? []); exit; }
$ctxVid = stream_context_create([
'http' => [
'header' => ['x-goog-api-key: ' . $API_KEY]
]
]);
$video = file_get_contents($videoUri, false, $ctxVid);
$fpath = __DIR__ . '/generated_' . time() . '.mp4';
file_put_contents($fpath, $video);
Metadata
Metadata
Assignees
Labels
No labels