Skip to content

Commit 7463910

Browse files
save file
1 parent aaba40b commit 7463910

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

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

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@
165165
{display:flex;flex-direction:column;gap:10px}
166166

167167
#results
168-
{display:flex;gap:20px}
168+
{display:flex;gap:20px;flex-wrap:wrap}
169169
.item
170-
{display:flex;flex-direction:column;gap:10px}
170+
{display:flex;flex-direction:column;gap:10px;border:1px solid lightgray;padding:10px;border-radius:10px}
171+
.item [type=checkbox]
172+
{}
171173

172174
#output
173175
{border:1px solid lightgray;padding:10px;border-radius:10px;white-space:pre-wrap;overflow:auto;font-size:16px;font-family:monospace;flex:1}
@@ -176,7 +178,10 @@
176178
{width:70px}
177179

178180
#png,#jpg
179-
{border:1px solid lightgray;padding:2px 10px;border-radius:10px}
181+
{border:1px solid lightgray;padding:5px 10px;border-radius:10px;display:inline-flex;align-items:center}
182+
183+
[type=checkbox]
184+
{margin-right:10px;width:20px;height:20px;cursor:pointer}
180185

181186
</style>
182187

@@ -239,6 +244,10 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
239244
<div class=item style='display:none'>
240245
<img class=thumbnail>
241246
<div>
247+
<div>
248+
<input type=checkbox>
249+
<div class=filename></div>
250+
</div>
242251
<div class=dims></div>
243252
<div class=size></div>
244253
</div>
@@ -288,7 +297,6 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
288297

289298
output = $('#output');
290299

291-
disp('loading');
292300

293301
if(window.parent.curvideo){
294302
complete.load(window.parent.curvideo.file,structuredClone(window.parent.curvideo.blob));
@@ -424,7 +432,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
424432
console.log(w,h,secs);
425433
var fn = cur.file.filename;
426434
var fn2 = fn.split('.')[0];
427-
var thumb = fn2+'.png';
435+
var thumb = fn2+`-${w}x${h}-${secs}s.png`;
428436

429437
var uint8 = await _uint8(cur.blob);
430438

@@ -437,7 +445,8 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
437445

438446
var data = await ffmpeg.readFile(thumb);
439447
var thumbnail = _blob(data);
440-
gen.complete(thumbnail,thumb);
448+
thumbnail.name = thumb;
449+
gen.complete(thumbnail,thumb,secs);
441450

442451
}//png
443452

@@ -446,7 +455,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
446455

447456
var fn = cur.file.filename;
448457
var fn2 = fn.split('.')[0];
449-
var thumb = fn2+'.jpg';
458+
var thumb = fn2+`-${w}x${h}-${secs}s.jpg`;
450459

451460
var uint8 = await _uint8(cur.blob);
452461

@@ -459,12 +468,13 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
459468

460469
var data = await ffmpeg.readFile(thumb);
461470
var thumbnail = _blob(data);
462-
gen.complete(thumbnail,thumb);
471+
thumbnail.name = thumb;
472+
gen.complete(thumbnail,thumb,secs);
463473

464474
}//jpg
465475

466476

467-
gen.complete = function(blob,fn){
477+
gen.complete = function(blob,fn,secs){
468478

469479
cur.status = false;
470480
var url = window.URL.createObjectURL(blob);
@@ -477,7 +487,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
477487

478488
function onload(){
479489

480-
$(nitem,'.dims').textContent = img.naturalWidth+' x '+img.naturalHeight;
490+
$(nitem,'.dims').textContent = img.naturalWidth+' x '+img.naturalHeight+` ( ${secs} s )`;
481491

482492
}//onload
483493

@@ -520,7 +530,8 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
520530

521531
;
522532
(async()=>{
523-
533+
disp('loading');
534+
524535
var {zip} = await import('https://cdn.jsdelivr.net/gh/javascript-2020/libs/js/io/tiny-unzip/tiny-unzip.m.js');
525536
var get = url=>fetch(url).then(res=>res.blob());
526537
var dtype = v=>Object.prototype.toString.call(v).slice(8,-1).toLowerCase();
@@ -591,7 +602,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
591602
ffmpeg.on('log',({message})=>{if(!ffmpeg_debug)return;console.log(message);disp(message)});
592603
await ffmpeg.exec(['-version']);
593604

594-
disp('ready');
605+
disp('ready');
595606

596607
})()
597608
;
@@ -601,7 +612,7 @@ <h1 slot=seo-hdr class=visually-hidden>video thumbnail generator</h1>
601612

602613
var div = document.createElement('div');
603614
div.textContent = str;
604-
output.append(div);
615+
document.querySelector('#output').append(div);
605616

606617
}//disp
607618

0 commit comments

Comments
 (0)