File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < script src ="/dist/ffmpeg.dev.js "> </ script >
4+ < style >
5+ html ,
6+ body {
7+ margin : 0 ;
8+ width : 100% ;
9+ height : 100% ;
10+ }
11+
12+ body {
13+ display : flex;
14+ flex-direction : column;
15+ align-items : center;
16+ }
17+ </ style >
18+ </ head >
19+
20+ < body >
21+ < h3 > Select multiple video files to Concatenate</ h3 >
22+ < video id ="output-video " controls > </ video > < br />
23+ < input type ="file " id ="uploader " multiple />
24+ < p id ="message "> </ p >
25+ < script >
26+ const { createWorker } = FFmpeg ;
27+ const worker = createWorker ( {
28+ corePath : "../../node_modules/@ffmpeg/core/ffmpeg-core.js" ,
29+ logger : ( { message } ) => console . log ( message )
30+ } ) ;
31+
32+ const transcode = async ( { target : { files } } ) => {
33+ const message = document . getElementById ( "message" ) ;
34+ message . innerHTML = "Loading ffmpeg-core.js" ;
35+ await worker . load ( ) ;
36+ message . innerHTML = "Start Concating" ;
37+ const inputPaths = [ ] ;
38+ for ( const file of files ) {
39+ const { name } = file ;
40+ await worker . write ( name , file ) ;
41+ inputPaths . push ( name ) ;
42+ }
43+ await worker . concatDemuxer ( inputPaths , "output.mp4" ) ;
44+ message . innerHTML = "Complete Concating" ;
45+ const { data } = await worker . read ( "output.mp4" ) ;
46+ const video = document . getElementById ( "output-video" ) ;
47+ video . src = URL . createObjectURL (
48+ new Blob ( [ data . buffer ] , {
49+ type : "video/mp4"
50+ } )
51+ ) ;
52+ } ;
53+ const elm = document . getElementById ( "uploader" ) ;
54+ elm . addEventListener ( "change" , transcode ) ;
55+ </ script >
56+ </ body >
57+ </ html >
You can’t perform that action at this time.
0 commit comments