feat: batch video upscaling with folder upload, directory save, and result comparison (#1051)

* feat: support batch video upscaling with folder upload and directory save

- Add multi-file selection and entire folder upload (webkitdirectory)
- Support drag & drop of both files and folders via FileSystemEntry API
- Add save directory picker using File System Access API (showDirectoryPicker)
- Process videos sequentially with per-file progress and status tracking
- Add right-side result list with click-to-compare functionality
- Add per-video duration and total batch duration display
- Add retry button for failed items with error detail display
- Remove auto-play on comparison viewer load
- Fix worker error handling: handle "error" command to reject stale promises
- Fix event listener accumulation in video comparison (AbortController)
- Fix XSS risk by escaping HTML in all innerHTML injections
- Fix URL revocation timing in download to prevent large file truncation
- Extract writeToSaveDirectory and truncateName helpers to reduce duplication
- Add Usage Guide panel explaining single/multiple/folder upload options

Files changed:
  docs/upscaler/index.html  (+1110/-181)
  docs/upscaler/upscaler.js (+110)

* fix: prevent auto-play and resource consumption during upscaling

- Set preload="metadata" on preview and comparison video elements
- Explicitly pause preview video after setting src in showVideoPreview
- Remove preview video seek sync from batch processing progress callbacks
  (was causing continuous decode during upscaling, wasting GPU resources)
- Remove preview video seek sync from retry progress callback
- All videos now require manual play; no background resource usage

* fix: improve upscaled video quality with higher bitrate and codec support

- Raise base bitrate from 2.5 Mbps (25e5) to 8 Mbps (8e6) for standard and
  firefox processors, preventing quality loss when source videos have high
  bitrates (e.g. 720p @ 16.7 Mbps was producing 1440p @ 10 Mbps, smaller
  than the original file)
- Double the bitrate for mediabunny processor (X.n1 * 2) to account for the
  4x pixel increase from 2x upscaling
- Add H.264 Level 5.1 (avc1.640033) and Level 5.2 (avc1.640034) codecs to
  the fallback lists, since Level 4.0 (avc1.640028, ~24.6 Mbps) cannot
  support the higher bitrates for 1440p+ outputs
- Add latencyMode: "quality" to VideoEncoder configs for both standard and
  firefox processors, prioritizing encoding quality over latency (suitable
  for offline processing)

* feat: add video data comparison panel for original vs upscaled metrics

- Add a comparison data table below the file info bar showing 6 metrics:
  Resolution, File Size, Duration, Est. Bitrate, Pixels, Process Time
- Display per-metric change percentage with color-coded indicators:
  green (↑) for improvements, red (↓) for regressions, gray for neutral
- Estimated bitrate calculated from file size × 8 / video duration
- Table renders after both original and upscaled video metadata loads
- Auto-hide panel on reset

* fix: make video data comparison panel full-width and responsive

- Move comparison data table from inside the left column to the full-width
  area below the left/right layout, so it is no longer constrained by the
  comparison viewer column width
- Remove table-fixed colgroup and overflow-x-auto that caused horizontal
  scrolling on smaller screens
- Table now uses w-full auto-layout, displaying all 4 columns (Metric,
  Original, Upscaled, Change) without requiring horizontal scrolling

---------

Co-authored-by: rionzhao <rionzhao@tencent.com>
This commit is contained in:
糖猫猫andrionzhao authored and GitHub committed 2026-09-10 17:19:38 +08:00
commit 0896841d23
538 files changed
+379715

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* monaco-css version: 0.30.1(5a7ba61be909ae9e4889768a3453ebb0dec392e2)
* Released under the MIT license
* https://github.com/Microsoft/monaco-css/blob/master/LICENSE.md
*-----------------------------------------------------------------------------*/
define("vs/language/css/workerManager",["require","exports","./fillers/monaco-editor-core"],(function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.WorkerManager=void 0;var i=function(){function e(e){var n=this;this._defaults=e,this._worker=null,this._idleCheckInterval=window.setInterval((function(){return n._checkIfIdle()}),3e4),this._lastUsedTime=0,this._configChangeListener=this._defaults.onDidChange((function(){return n._stopWorker()}))}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){clearInterval(this._idleCheckInterval),this._configChangeListener.dispose(),this._stopWorker()},e.prototype._checkIfIdle=function(){this._worker&&(Date.now()-this._lastUsedTime>12e4&&this._stopWorker())},e.prototype._getClient=function(){return this._lastUsedTime=Date.now(),this._client||(this._worker=t.editor.createWebWorker({moduleId:"vs/language/css/cssWorker",label:this._defaults.languageId,createData:{options:this._defaults.options,languageId:this._defaults.languageId}}),this._client=this._worker.getProxy()),this._client},e.prototype.getLanguageServiceWorker=function(){for(var e,n=this,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return this._getClient().then((function(n){e=n})).then((function(e){return n._worker.withSyncedResources(t)})).then((function(n){return e}))},e}();n.WorkerManager=i})),function(e){if("object"==typeof module&&"object"==typeof module.exports){var n=e(require,exports);void 0!==n&&(module.exports=n)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}((function(e,n){"use strict";var t,i,r,o,a,s,u,c,d,g,l,f,h,p,m,v,y;Object.defineProperty(n,"__esModule",{value:!0}),n.TextDocument=n.EOL=n.SelectionRange=n.DocumentLink=n.FormattingOptions=n.CodeLens=n.CodeAction=n.CodeActionContext=n.CodeActionKind=n.DocumentSymbol=n.SymbolInformation=n.SymbolTag=n.SymbolKind=n.DocumentHighlight=n.DocumentHighlightKind=n.SignatureInformation=n.ParameterInformation=n.Hover=n.MarkedString=n.CompletionList=n.CompletionItem=n.InsertTextMode=n.InsertReplaceEdit=n.CompletionItemTag=n.InsertTextFormat=n.CompletionItemKind=n.MarkupContent=n.MarkupKind=n.TextDocumentItem=n.OptionalVersionedTextDocumentIdentifier=n.VersionedTextDocumentIdentifier=n.TextDocumentIdentifier=n.WorkspaceChange=n.WorkspaceEdit=n.DeleteFile=n.RenameFile=n.CreateFile=n.TextDocumentEdit=n.AnnotatedTextEdit=n.ChangeAnnotationIdentifier=n.ChangeAnnotation=n.TextEdit=n.Command=n.Diagnostic=n.CodeDescription=n.DiagnosticTag=n.DiagnosticSeverity=n.DiagnosticRelatedInformation=n.FoldingRange=n.FoldingRangeKind=n.ColorPresentation=n.ColorInformation=n.Color=n.LocationLink=n.Location=n.Range=n.Position=n.uinteger=n.integer=void 0,function(e){e.MIN_VALUE=-2147483648,e.MAX_VALUE=2147483647}(n.integer||(n.integer={})),function(e){e.MIN_VALUE=0,e.MAX_VALUE=2147483647}(t=n.uinteger||(n.uinteger={})),function(e){e.create=function(e,n){return e===Number.MAX_VALUE&&(e=t.MAX_VALUE),n===Number.MAX_VALUE&&(n=t.MAX_VALUE),{line:e,character:n}},e.is=function(e){var n=e;return A.objectLiteral(n)&&A.uinteger(n.line)&&A.uinteger(n.character)}}(i=n.Position||(n.Position={})),function(e){e.create=function(e,n,t,r){if(A.uinteger(e)&&A.uinteger(n)&&A.uinteger(t)&&A.uinteger(r))return{start:i.create(e,n),end:i.create(t,r)};if(i.is(e)&&i.is(n))return{start:e,end:n};throw new Error("Range#create called with invalid arguments["+e+", "+n+", "+t+", "+r+"]")},e.is=function(e){var n=e;return A.objectLiteral(n)&&i.is(n.start)&&i.is(n.end)}}(r=n.Range||(n.Range={})),function(e){e.create=function(e,n){return{uri:e,range:n}},e.is=function(e){var n=e;return A.defined(n)&&r.is(n.range)&&(A.string(n.uri)||A.undefined(n.uri))}}(o=n.Location||(n.Location={})),function(e){e.create=function(e,n,t,i){return{targetUri:e,targetRange:n,targetSelectionRange:t,originSelectionRange:i}},e.is=function(e){var n=e;return A.defined(n)&&r.is(n.targetRange)&&A.string(n.targetUri)&&(r.is(n.targetSelectionRange)||A.undefined(n.targetSelectionRange))&&(r.is(n.originSelectionRange)||A.undefined(n.originSelectionRange))}}(n.LocationLink||(n.LocationLink={})),function(e){e.create=function(e,n,t,i){return{red:e,green:n,blue:t,alpha:i}},e.is=function(e){var n=e;return A.numberRange(n.red,0,1)&&A.numberRange(n.green,0,1)&&A.numberRange(n.blue,0,1)&&A.numberRange(n.alpha,0,1)}}(a=n.Color||(n.Color={})),function(e){e.create=function(e,n){return{range:e,color:n}},e.is=function(e){var n=e;return r.is(n.range)&&a.is(n.color)}}(n.ColorInformation||(n.ColorInformation={})),function(e){e.create=function(e,n,t){return{label:e,textEdit:n,additionalTextEdits:t}},e.is=function(e){var n=e;return A.string(n.label)&&(A.undefined(n.textEdit)||d.is(n))&&(A.undefined(n.additionalTextEdits)||A.typedArray(n.additionalTextEdits,d.is))}}(n.ColorPresentation||(n.ColorPresentation={})),function(e){e.Comment="comment",e.Imports="imports",e.Region="region"}(n.Line truncated