Skip to content

Commit cedca9d

Browse files
save file
1 parent f620c64 commit cedca9d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

utils/video/video-thumbnail-generator/video-thumbnail-generator.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
259259
disp('loading');
260260

261261
if(window.parent.curvideo){
262-
complete.load(window.parent.curvideo.file,window.parent.curvideo.blob);
262+
complete.load(window.parent.curvideo.file,structuredClone(window.parent.curvideo.blob));
263263
}
264264

265265

@@ -325,14 +325,16 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
325325
var fn = cur.file.filename;
326326
var fn2 = fn.split('.')[0];
327327
var thumb = fn2+'.png';
328-
debugger;
328+
329329
var uint8 = await _uint8(cur.blob);
330330

331331
await ffmpeg.writeFile(fn,uint8);
332332

333333
var cmd = `ffmpeg -nostdin -ss 00:00:03.00 -i ${fn} -vframes 1 -vf scale=-1:50 ${thumb}`;
334334
var args = cmd.split(' ').slice(1);
335335

336+
await ffmpeg.exec(args);
337+
336338
var data = await ffmpeg.readFile(thumb);
337339
var thumbnail = _blob(data);
338340
gen.complete(thumbnail,thumb);
@@ -368,15 +370,15 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
368370

369371
window.parent.curvideo = {};
370372
window.parent.curvideo.file = file;
371-
window.parent.curvideo.blob = blob;
373+
window.parent.curvideo.blob = structuredClone(blob);
372374

373375
cur.file = file;
374376
cur.blob = blob;
375377
var url = window.URL.createObjectURL(blob);
376378
video.src = url;
377379

378380
$('#video-filename').textContent = file.filename;
379-
$('#video-size').textContent = blob.size;
381+
$('#video-size').textContent = hs(blob.size);
380382

381383
}//load
382384

@@ -392,22 +394,22 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
392394

393395
var {zip} = await import('https://cdn.jsdelivr.net/gh/javascript-2020/libs/js/io/tiny-unzip/tiny-unzip.m.js');
394396
var get = url=>fetch(url).then(res=>res.blob());
397+
var dtype = v=>Object.prototype.toString.call(v).slice(8,-1).toLowerCase();
398+
var fnstr = (fn,_,js,i1,i2)=>(js=fn+'',i1=js.indexOf('{'),i2=js.lastIndexOf('}'),js.slice(i1+1,i2));
399+
_blob = v=>new Blob([v]);
400+
_uint8 = async v=>(dtype(v)=='blob'||dtype(v)=='file') ? new Uint8Array(await v.arrayBuffer()) : new Uint8Array(v);
395401

396402
var blob;
403+
console.log(window.parent['ffmpeg-wasm']);
397404
//delete window.parent['ffmpeg-wasm'];
398405
if(window.parent['ffmpeg-wasm']){
399406
disp('** ffmpeg-wasm **');
400-
blob = window.parent['ffmpeg-wasm'];
407+
blob = structuredClone(window.parent['ffmpeg-wasm']);
401408
}else{
402409
blob = await get('https://raw.githubusercontent.com/javascript-2020/external/main/ffmpeg/ffmpeg-wasm/ffmpeg-wasm.zip');
403-
window.parent['ffmpeg-wasm'] = blob;
410+
window.parent['ffmpeg-wasm'] = structuredClone(blob);
404411
}
405412

406-
var dtype = v=>Object.prototype.toString.call(v).slice(8,-1).toLowerCase();
407-
var fnstr = (fn,_,js,i1,i2)=>(js=fn+'',i1=js.indexOf('{'),i2=js.lastIndexOf('}'),js.slice(i1+1,i2));
408-
_blob = v=>new Blob([v]);
409-
_uint8 = async v=>(dtype(v)=='blob'||dtype(v)=='file') ? new Uint8Array(await v.arrayBuffer()) : new Uint8Array(v);
410-
411413
var files = await zip.rd(blob);
412414
files.forEach(({name,blob})=>files[name]=blob);
413415
files['ffmpeg-core.wasm'] = window.URL.createObjectURL(files['ffmpeg-core.wasm']);

0 commit comments

Comments
 (0)