mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
Merge pull request #46 from storytold/feature/resume-single-frame
Completed single frame render except for UI.
This commit is contained in:
2 files changed
+48
-3
No files matched your search
@@ -313,6 +313,41 @@ class APIManager {
|
||||
}
|
||||
}
|
||||
|
||||
public async uploadMediaFrameGeneration(
|
||||
blob: any,
|
||||
fileName: string,
|
||||
style: string = "comic_book",
|
||||
positive_prompt: string,
|
||||
negative_prompt: string,
|
||||
): Promise<string> {
|
||||
const url = `https://funnel.tailce84f.ts.net/preview/`;
|
||||
|
||||
const payload = {
|
||||
style: style,
|
||||
positive_prompt: positive_prompt,
|
||||
negative_prompt: negative_prompt
|
||||
};
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("video", blob, fileName);
|
||||
formData.append("request", JSON.stringify(payload));
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new APIManagerResponseError("Upload Media Failed to send file");
|
||||
} else {
|
||||
return URL.createObjectURL(await response.blob());
|
||||
}
|
||||
}
|
||||
|
||||
public async getMediaBatch(media_tokens: string[]): Promise<MediaFile[]> {
|
||||
const tokens = media_tokens;
|
||||
const url = new URL(`${this.baseUrl}/v1/media_files/batch`);
|
||||
|
||||
@@ -903,7 +903,6 @@ class Editor {
|
||||
let imgData = this.renderer.domElement.toDataURL();
|
||||
this.activeScene.renderMode(false);
|
||||
this.onWindowResize();
|
||||
|
||||
let ffmpeg = createFFmpeg({ log: false });
|
||||
await ffmpeg.load();
|
||||
await ffmpeg.FS(
|
||||
@@ -914,10 +913,21 @@ class Editor {
|
||||
await ffmpeg.run('-i', `render.png`, 'render.mp4');
|
||||
let output = await ffmpeg.FS("readFile", 'render.mp4');
|
||||
const blob = new Blob([output.buffer], { type: "video/mp4" });
|
||||
let data = await this.api_manager.uploadMedia(blob, "render.wav");
|
||||
|
||||
//const blob = new Blob([imgData], { type: "image/png" });
|
||||
let url = await this.api_manager.uploadMediaFrameGeneration(blob, "render.mp4", "anime_ghibli", "((masterpiece, best quality, 8K, detailed)), colorful, epic, fantasy, (fox, red fox:1.2), no humans, 1other, ((koi pond)), outdoors, pond, rocks, stones, koi fish, ((watercolor))), lilypad, fish swimming around.", "");
|
||||
|
||||
const downloadLink = document.createElement("a");
|
||||
downloadLink.href = url;
|
||||
downloadLink.download = "render.mp4";
|
||||
document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
// Clean up
|
||||
URL.revokeObjectURL(url);
|
||||
document.body.removeChild(downloadLink);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(data);
|
||||
resolve(url);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user