Update app.py
Browse files
app.py
CHANGED
|
@@ -625,9 +625,20 @@ doExport();
|
|
| 625 |
}}
|
| 626 |
|
| 627 |
async function doExport(){{
|
|
|
|
| 628 |
var canvas=document.createElement('canvas');
|
| 629 |
canvas.width=1280;canvas.height=720;
|
| 630 |
var ctx=canvas.getContext('2d');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
var stream=canvas.captureStream(30);
|
| 632 |
|
| 633 |
// ๊ณ ํ์ง ์ค์
|
|
@@ -659,8 +670,9 @@ var t=frame*frameTime;
|
|
| 659 |
document.getElementById('exportBar').style.width=(frame/totalFrames*100)+'%';
|
| 660 |
document.getElementById('exportMsg').textContent='๋
นํ ์ค... '+Math.round(frame/totalFrames*100)+'% ('+Math.floor(t)+'/'+Math.floor(dur)+'์ด)';
|
| 661 |
|
| 662 |
-
|
| 663 |
-
|
|
|
|
| 664 |
|
| 665 |
var vc=getClipAt(t,'visual');
|
| 666 |
if(vc){{
|
|
@@ -668,7 +680,6 @@ var el=S.els[vc.mid];
|
|
| 668 |
if(el){{
|
| 669 |
if(vc.type==='video'){{
|
| 670 |
var clipT=t-vc.start+vc.ts;
|
| 671 |
-
// seekํ๊ณ ์๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆผ
|
| 672 |
await seekVideo(el,clipT);
|
| 673 |
}}
|
| 674 |
try{{
|
|
@@ -676,12 +687,15 @@ var sw=el.videoWidth||el.naturalWidth||el.width||1280;
|
|
| 676 |
var sh=el.videoHeight||el.naturalHeight||el.height||720;
|
| 677 |
var scale=Math.min(1280/sw,720/sh);
|
| 678 |
var dw=sw*scale,dh=sh*scale;
|
| 679 |
-
|
| 680 |
}}catch(e){{}}
|
| 681 |
}}
|
| 682 |
}}
|
| 683 |
|
| 684 |
-
// ํ๋ ์
|
|
|
|
|
|
|
|
|
|
| 685 |
await new Promise(function(resolve){{setTimeout(resolve,33)}});
|
| 686 |
}}
|
| 687 |
|
|
@@ -743,7 +757,6 @@ resolve();
|
|
| 743 |
}};
|
| 744 |
video.addEventListener('seeked',onSeeked);
|
| 745 |
video.currentTime=time;
|
| 746 |
-
// ํ์์์ (ํน์ seeked ์ด๋ฒคํธ๊ฐ ์ ์ค๋ฉด)
|
| 747 |
setTimeout(resolve,200);
|
| 748 |
}});
|
| 749 |
}}
|
|
|
|
| 625 |
}}
|
| 626 |
|
| 627 |
async function doExport(){{
|
| 628 |
+
// ๋ฉ์ธ ์บ๋ฒ์ค (MediaRecorder ์ฐ๊ฒฐ์ฉ)
|
| 629 |
var canvas=document.createElement('canvas');
|
| 630 |
canvas.width=1280;canvas.height=720;
|
| 631 |
var ctx=canvas.getContext('2d');
|
| 632 |
+
|
| 633 |
+
// ์คํ์คํฌ๋ฆฐ ์บ๋ฒ์ค (๋ ๋๋ง์ฉ - ๋๋ธ ๋ฒํผ๋ง)
|
| 634 |
+
var offCanvas=document.createElement('canvas');
|
| 635 |
+
offCanvas.width=1280;offCanvas.height=720;
|
| 636 |
+
var offCtx=offCanvas.getContext('2d');
|
| 637 |
+
|
| 638 |
+
// ์ด๊ธฐ ๊ฒ์ ํ๋ฉด
|
| 639 |
+
ctx.fillStyle='#000';
|
| 640 |
+
ctx.fillRect(0,0,1280,720);
|
| 641 |
+
|
| 642 |
var stream=canvas.captureStream(30);
|
| 643 |
|
| 644 |
// ๊ณ ํ์ง ์ค์
|
|
|
|
| 670 |
document.getElementById('exportBar').style.width=(frame/totalFrames*100)+'%';
|
| 671 |
document.getElementById('exportMsg').textContent='๋
นํ ์ค... '+Math.round(frame/totalFrames*100)+'% ('+Math.floor(t)+'/'+Math.floor(dur)+'์ด)';
|
| 672 |
|
| 673 |
+
// ์คํ์คํฌ๋ฆฐ ์บ๋ฒ์ค์ ๋จผ์ ๊ทธ๋ฆผ
|
| 674 |
+
offCtx.fillStyle='#000';
|
| 675 |
+
offCtx.fillRect(0,0,1280,720);
|
| 676 |
|
| 677 |
var vc=getClipAt(t,'visual');
|
| 678 |
if(vc){{
|
|
|
|
| 680 |
if(el){{
|
| 681 |
if(vc.type==='video'){{
|
| 682 |
var clipT=t-vc.start+vc.ts;
|
|
|
|
| 683 |
await seekVideo(el,clipT);
|
| 684 |
}}
|
| 685 |
try{{
|
|
|
|
| 687 |
var sh=el.videoHeight||el.naturalHeight||el.height||720;
|
| 688 |
var scale=Math.min(1280/sw,720/sh);
|
| 689 |
var dw=sw*scale,dh=sh*scale;
|
| 690 |
+
offCtx.drawImage(el,(1280-dw)/2,(720-dh)/2,dw,dh);
|
| 691 |
}}catch(e){{}}
|
| 692 |
}}
|
| 693 |
}}
|
| 694 |
|
| 695 |
+
// ์์ฑ๋ ํ๋ ์์ ๋ฉ์ธ ์บ๋ฒ์ค๋ก ํ ๋ฒ์ ๋ณต์ฌ (๊น๋นก์ ๋ฐฉ์ง)
|
| 696 |
+
ctx.drawImage(offCanvas,0,0);
|
| 697 |
+
|
| 698 |
+
// ํ๋ ์ ๊ฐ๊ฒฉ๋งํผ ๋๊ธฐ
|
| 699 |
await new Promise(function(resolve){{setTimeout(resolve,33)}});
|
| 700 |
}}
|
| 701 |
|
|
|
|
| 757 |
}};
|
| 758 |
video.addEventListener('seeked',onSeeked);
|
| 759 |
video.currentTime=time;
|
|
|
|
| 760 |
setTimeout(resolve,200);
|
| 761 |
}});
|
| 762 |
}}
|