fffiloni commited on
Commit
62ec771
1 Parent(s): b037e0c

Update share_btn.py

Browse files
Files changed (1) hide show
  1. share_btn.py +9 -18
share_btn.py CHANGED
@@ -16,7 +16,7 @@ async () => {
16
  const response = await fetch(UPLOAD_URL, {
17
  method: 'POST',
18
  headers: {
19
- 'Content-Type': 'video/mp4',
20
  'X-Requested-With': 'XMLHttpRequest',
21
  },
22
  body: file, /// <- File inherits from Blob
@@ -25,22 +25,13 @@ async () => {
25
  return url;
26
  }
27
 
28
- async function getOutputVideoFile(videoURL){
29
-
30
- fetch(videoURL)
31
- .then(response => response.blob())
32
- .then(blob => {
33
- // do something with the blob;
34
- console.log(blob);
35
-
36
- //let videoBlob = URL.createObjectURL(blob);
37
-
38
- let videoBlob = new File([blob], { type: 'video/mp4' });
39
- console.log(videoBlob);
40
- return videoBlob;
41
- });
42
-
43
- }
44
 
45
 
46
  const gradioEl = document.querySelector("gradio-app").shadowRoot || document.querySelector('body > gradio-app');
@@ -68,7 +59,7 @@ async () => {
68
  shareIconEl.style.display = 'none';
69
  loadingIconEl.style.removeProperty('display');
70
 
71
- const videoFile = await getOutputVideoFile(outputVideo_src);
72
  const dataOutputVideo = await uploadFile(videoFile);
73
 
74
 
 
16
  const response = await fetch(UPLOAD_URL, {
17
  method: 'POST',
18
  headers: {
19
+ 'Content-Type': file.type,
20
  'X-Requested-With': 'XMLHttpRequest',
21
  },
22
  body: file, /// <- File inherits from Blob
 
25
  return url;
26
  }
27
 
28
+ async function getInputVideoFile(videoEl){
29
+ const res = await fetch(videoEl.src);
30
+ const blob = await res.blob();
31
+ const videoId = Date.now() % 200;
32
+ const fileName = `gpt-talking-portrai-${{videoId}}.mp4`;
33
+ return new File([blob], fileName, { type: 'video/mp4' });
34
+ }
 
 
 
 
 
 
 
 
 
35
 
36
 
37
  const gradioEl = document.querySelector("gradio-app").shadowRoot || document.querySelector('body > gradio-app');
 
59
  shareIconEl.style.display = 'none';
60
  loadingIconEl.style.removeProperty('display');
61
 
62
+ const videoFile = await getInputVideoFile(outputVideo);
63
  const dataOutputVideo = await uploadFile(videoFile);
64
 
65