diff --git a/README.md b/README.md index aae1509..419b73e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ npx @grom13/dvc-cli video.mp4 # Или глобальная установка npm install -g @grom13/dvc-cli -dvc video.mp4 +dvc-cli video.mp4 ``` **Системные требования:** @@ -32,7 +32,7 @@ brew install ffmpeg gpac ## Параметры CLI ```bash -dvc [output-dir] [-r resolutions] [-p poster-timecode] +dvc-cli [output-dir] [-r resolutions] [-p poster-timecode] ``` ### Основные параметры @@ -53,25 +53,25 @@ dvc [output-dir] [-r resolutions] [-p poster-timecode] ```bash # Базовая конвертация (результат в текущей папке) -dvc video.mp4 +dvc-cli video.mp4 # Указать выходную директорию -dvc video.mp4 ./output +dvc-cli video.mp4 ./output # Только выбранные разрешения -dvc video.mp4 -r 720,1080,1440 +dvc-cli video.mp4 -r 720,1080,1440 # Высокий FPS для игровых стримов -dvc video.mp4 -r 720@60,1080@60 +dvc-cli video.mp4 -r 720@60,1080@60 # Постер с 5-й секунды -dvc video.mp4 -p 5 +dvc-cli video.mp4 -p 5 # Постер в формате времени -dvc video.mp4 -p 00:01:30 +dvc-cli video.mp4 -p 00:01:30 # Комбинация параметров -dvc video.mp4 ./output -r 720,1080@60,1440@60 -p 00:00:10 +dvc-cli video.mp4 ./output -r 720,1080@60,1440@60 -p 00:00:10 ``` ### Поддерживаемые разрешения diff --git a/bin/cli.js b/bin/cli.js index 6db5ba4..dc4e933 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -1,19 +1,23 @@ #!/usr/bin/env node -import{createRequire as Xu}from"node:module";var qu=Object.create;var{getPrototypeOf:Zu,defineProperty:qD,getOwnPropertyNames:Lu}=Object;var Qu=Object.prototype.hasOwnProperty;var g=(u,D,F)=>{F=u!=null?qu(Zu(u)):{};let C=D||!u||!u.__esModule?qD(F,"default",{value:u,enumerable:!0}):F;for(let E of Lu(u))if(!Qu.call(C,E))qD(C,E,{get:()=>u[E],enumerable:!0});return C};var I=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var N=Xu(import.meta.url);var RD=I((hF,ID)=>{class GD{constructor(u,D,F){this.etaBufferLength=u||100,this.valueBuffer=[F],this.timeBuffer=[D],this.eta="0"}update(u,D,F){this.valueBuffer.push(D),this.timeBuffer.push(u),this.calculate(F-D)}getTime(){return this.eta}calculate(u){let D=this.valueBuffer.length,F=Math.min(this.etaBufferLength,D),C=this.valueBuffer[D-1]-this.valueBuffer[D-F],E=this.timeBuffer[D-1]-this.timeBuffer[D-F],A=C/E;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let B=Math.ceil(u/A/1000);if(isNaN(B))this.eta="NULL";else if(!isFinite(B))this.eta="INF";else if(B>1e7)this.eta="INF";else if(B<0)this.eta=0;else this.eta=B}}ID.exports=GD});var a=I((PF,xD)=>{var k=N("readline");class $D{constructor(u){this.stream=u,this.linewrap=!0,this.dy=0}cursorSave(){if(!this.stream.isTTY)return;this.stream.write("\x1B7")}cursorRestore(){if(!this.stream.isTTY)return;this.stream.write("\x1B8")}cursor(u){if(!this.stream.isTTY)return;if(u)this.stream.write("\x1B[?25h");else this.stream.write("\x1B[?25l")}cursorTo(u=null,D=null){if(!this.stream.isTTY)return;k.cursorTo(this.stream,u,D)}cursorRelative(u=null,D=null){if(!this.stream.isTTY)return;this.dy=this.dy+D,k.moveCursor(this.stream,u,D)}cursorRelativeReset(){if(!this.stream.isTTY)return;k.moveCursor(this.stream,0,-this.dy),k.cursorTo(this.stream,0,null),this.dy=0}clearRight(){if(!this.stream.isTTY)return;k.clearLine(this.stream,1)}clearLine(){if(!this.stream.isTTY)return;k.clearLine(this.stream,0)}clearBottom(){if(!this.stream.isTTY)return;k.clearScreenDown(this.stream)}newline(){this.stream.write(` -`),this.dy++}write(u,D=!1){if(this.linewrap===!0&&D===!1)this.stream.write(u.substr(0,this.getWidth()));else this.stream.write(u)}lineWrapping(u){if(!this.stream.isTTY)return;if(this.linewrap=u,u)this.stream.write("\x1B[?7h");else this.stream.write("\x1B[?7l")}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}}xD.exports=$D});var UD=I((fF,HD)=>{HD.exports=({onlyFirst:u=!1}={})=>{let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}});var _D=I((cF,WD)=>{var Vu=UD();WD.exports=(u)=>typeof u==="string"?u.replace(Vu(),""):u});var yD=I((gF,p)=>{var kD=(u)=>{if(Number.isNaN(u))return!1;if(u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141))return!0;return!1};p.exports=kD;p.exports.default=kD});var MD=I((mF,VD)=>{VD.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var SD=I((dF,s)=>{var Mu=_D(),zu=yD(),Su=MD(),zD=(u)=>{if(typeof u!=="string"||u.length===0)return 0;if(u=Mu(u),u.length===0)return 0;u=u.replace(Su()," ");let D=0;for(let F=0;F=127&&C<=159)continue;if(C>=768&&C<=879)continue;if(C>65535)F++;D+=zu(C)?2:1}return D};s.exports=zD;s.exports.default=zD});var n=I((lF,ND)=>{ND.exports=function(D,F,C){if(F.autopadding!==!0)return D;function E(A,B){return(F.autopaddingChar+A).slice(-B)}switch(C){case"percentage":return E(D,3);default:return D}}});var r=I((aF,wD)=>{wD.exports=function(D,F){let C=Math.round(D*F.barsize),E=F.barsize-C;return F.barCompleteString.substr(0,C)+F.barGlue+F.barIncompleteString.substr(0,E)}});var i=I((pF,jD)=>{jD.exports=function(D,F,C){function E(B){if(C)return C*Math.round(B/C);else return B}function A(B){return(F.autopaddingChar+B).slice(-2)}if(D>3600)return A(Math.floor(D/3600))+"h"+A(E(D%3600/60))+"m";else if(D>60)return A(Math.floor(D/60))+"m"+A(E(D%60))+"s";else if(D>10)return A(E(D))+"s";else return A(D)+"s"}});var t=I((sF,TD)=>{var Nu=SD(),wu=n(),ju=r(),Tu=i();TD.exports=function(D,F,C){let E=D.format,A=D.formatTime||Tu,B=D.formatValue||wu,q=D.formatBar||ju,Q=Math.floor(F.progress*100)+"",Z=F.stopTime||Date.now(),L=Math.round((Z-F.startTime)/1000),K=Object.assign({},C,{bar:q(F.progress,D),percentage:B(Q,D,"percentage"),total:B(F.total,D,"total"),value:B(F.value,D,"value"),eta:B(F.eta,D,"eta"),eta_formatted:A(F.eta,D,5),duration:B(L,D,"duration"),duration_formatted:A(L,D,1)});E=E.replace(/\{(\w+)\}/g,function(Y,R){if(typeof K[R]<"u")return K[R];return Y});let X=Math.max(0,F.maxWidth-Nu(E)-2),G=Math.floor(X/2);switch(D.align){case"right":E=X>0?" ".repeat(X)+E:E;break;case"center":E=G>0?" ".repeat(G)+E:E;break;case"left":default:break}return E}});var f=I((nF,OD)=>{function J(u,D){if(typeof u>"u"||u===null)return D;else return u}OD.exports={parse:function(D,F){let C={},E=Object.assign({},F,D);return C.throttleTime=1000/J(E.fps,10),C.stream=J(E.stream,process.stderr),C.terminal=J(E.terminal,null),C.clearOnComplete=J(E.clearOnComplete,!1),C.stopOnComplete=J(E.stopOnComplete,!1),C.barsize=J(E.barsize,40),C.align=J(E.align,"left"),C.hideCursor=J(E.hideCursor,!1),C.linewrap=J(E.linewrap,!1),C.barGlue=J(E.barGlue,""),C.barCompleteChar=J(E.barCompleteChar,"="),C.barIncompleteChar=J(E.barIncompleteChar,"-"),C.format=J(E.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),C.formatTime=J(E.formatTime,null),C.formatValue=J(E.formatValue,null),C.formatBar=J(E.formatBar,null),C.etaBufferLength=J(E.etaBuffer,10),C.etaAsynchronousUpdate=J(E.etaAsynchronousUpdate,!1),C.progressCalculationRelative=J(E.progressCalculationRelative,!1),C.synchronousUpdate=J(E.synchronousUpdate,!0),C.noTTYOutput=J(E.noTTYOutput,!1),C.notTTYSchedule=J(E.notTTYSchedule,2000),C.emptyOnZero=J(E.emptyOnZero,!1),C.forceRedraw=J(E.forceRedraw,!1),C.autopadding=J(E.autopadding,!1),C.gracefulExit=J(E.gracefulExit,!1),C},assignDerivedOptions:function(D){return D.barCompleteString=D.barCompleteChar.repeat(D.barsize+1),D.barIncompleteString=D.barIncompleteChar.repeat(D.barsize+1),D.autopaddingChar=D.autopadding?J(D.autopaddingChar," "):"",D}}});var e=I((rF,vD)=>{var bD=RD(),Ou=a(),bu=t(),vu=f(),hu=N("events");vD.exports=class extends hu{constructor(D){super();this.options=vu.assignDerivedOptions(D),this.terminal=this.options.terminal?this.options.terminal:new Ou(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new bD(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format==="function"?this.options.format:bu}render(D=!1){let F={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};if(this.options.etaAsynchronousUpdate)this.updateETA();let C=this.formatter(this.options,F,this.payload);if(D||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=C)this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(C),this.terminal.clearRight(),this.lastDrawnString=C,this.lastRedraw=Date.now(),this.emit("redraw-post")}start(D,F,C){this.value=F||0,this.total=typeof D<"u"&&D>=0?D:100,this.startValue=F||0,this.payload=C||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new bD(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",D,F)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(D,F={}){if(typeof D==="number")this.value=D,this.eta.update(Date.now(),D,this.total);let C=(typeof D==="object"?D:F)||{};this.emit("update",this.total,this.value);for(let E in C)this.payload[E]=C[E];if(this.value>=this.getTotal()&&this.options.stopOnComplete)this.stop()}getProgress(){let D=this.value/this.total;if(this.options.progressCalculationRelative)D=(this.value-this.startValue)/(this.total-this.startValue);if(isNaN(D))D=this.options&&this.options.emptyOnZero?0:1;return D=Math.min(Math.max(D,0),1),D}increment(D=1,F={}){if(typeof D==="object")this.update(this.value+1,D);else this.update(this.value+D,F)}getTotal(){return this.total}setTotal(D){if(typeof D<"u"&&D>=0)this.total=D}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var PD=I((iF,hD)=>{var Pu=e(),fu=f();hD.exports=class extends Pu{constructor(D,F){super(fu.parse(D,F));if(this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.options.synchronousUpdate=!1;this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline();this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(D,F){if(!this.timer)return;if(super.update(D,F),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2{var cu=a(),gu=e(),mu=f(),du=N("events");fD.exports=class extends du{constructor(D,F){super();this.bars=[],this.options=mu.parse(D,F),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new cu(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(D,F,C,E={}){let A=new gu(Object.assign({},this.options,{terminal:this.terminal},E));if(this.bars.push(A),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return A;if(this.sigintCallback===null&&this.options.gracefulExit)this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback);if(!this.isActive){if(this.options.hideCursor===!0)this.terminal.cursor(!1);if(this.options.linewrap===!1)this.terminal.lineWrapping(!1);this.timer=setTimeout(this.update.bind(this),this.schedulingRate)}return this.isActive=!0,A.start(D,F,C),this.emit("start"),A}remove(D){let F=this.bars.indexOf(D);if(F<0)return!1;return this.bars.splice(F,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0}update(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0){this.terminal.clearLine();while(this.loggingBuffer.length>0)this.terminal.write(this.loggingBuffer.shift(),!0)}for(let D=0;D0)this.terminal.newline();this.bars[D].render()}if(this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline(),this.terminal.newline();if(this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find((D)=>D.isActive))this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback)process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null;if(this.isActive=!1,this.options.hideCursor===!0)this.terminal.cursor(!0);if(this.options.linewrap===!1)this.terminal.lineWrapping(!0);if(this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let D=0;D0)this.terminal.newline();this.bars[D].render(),this.bars[D].stop()}this.terminal.newline()}this.emit("stop")}log(D){this.loggingBuffer.push(D)}}});var mD=I((eF,gD)=>{gD.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var lD=I((oF,dD)=>{dD.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var pD=I((DC,aD)=>{aD.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var nD=I((uC,sD)=>{sD.exports={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "}});var iD=I((FC,rD)=>{var lu=mD(),au=lD(),pu=pD(),su=nD();rD.exports={legacy:lu,shades_classic:au,shades_grey:pu,rect:su}});var oD=I((CC,eD)=>{var tD=PD(),nu=cD(),ru=iD(),iu=t(),tu=n(),eu=r(),ou=i();eD.exports={Bar:tD,SingleBar:tD,MultiBar:nu,Presets:ru,Format:{Formatter:iu,BarFormat:eu,ValueFormat:tu,TimeFormat:ou}}});import{join as KD,basename as Uu,extname as Wu}from"node:path";import{randomUUID as _u}from"node:crypto";import{rm as ku}from"node:fs/promises";import{spawn as w}from"node:child_process";async function y(){return new Promise((u)=>{let D=w("ffmpeg",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function V(){return new Promise((u)=>{let D=w("MP4Box",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function M(){return new Promise((u)=>{let D=w("ffmpeg",["-hide_banner","-encoders"]),F="";D.stdout.on("data",(C)=>{F+=C.toString()}),D.on("error",()=>u(!1)),D.on("close",(C)=>{if(C!==0)u(!1);else u(F.includes("h264_nvenc")||F.includes("hevc_nvenc"))})})}async function z(u,D,F){return new Promise((C,E)=>{let A=w("ffmpeg",u),B="";A.stderr.on("data",(q)=>{let Q=q.toString();if(B+=Q,D&&F){let Z=Q.match(/time=(\d{2}):(\d{2}):(\d{2}\.\d{2})/);if(Z){let L=parseInt(Z[1]),K=parseInt(Z[2]),X=parseFloat(Z[3]),G=L*3600+K*60+X,Y=Math.min(100,G/F*100);D(Y)}}}),A.on("error",(q)=>{E(Error(`FFmpeg error: ${q.message}`))}),A.on("close",(q)=>{if(q===0)C();else E(Error(`FFmpeg failed with exit code ${q} -${B}`))})})}async function m(u){return new Promise((D,F)=>{let C=w("MP4Box",u),E="",A="";C.stdout.on("data",(B)=>{E+=B.toString()}),C.stderr.on("data",(B)=>{A+=B.toString()}),C.on("error",(B)=>{F(Error(`MP4Box error: ${B.message}`))}),C.on("close",(B)=>{if(B===0)D();else F(Error(`MP4Box failed with exit code ${B} -${A||E}`))})})}import{spawn as Yu}from"node:child_process";async function b(u){return new Promise((D,F)=>{let C=Yu("ffprobe",["-v","error","-select_streams","v:0","-show_entries","stream=width,height,duration,r_frame_rate,codec_name","-select_streams","a:0","-show_entries","stream=bit_rate","-show_entries","format=duration","-of","json",u]),E="";C.stdout.on("data",(A)=>{E+=A.toString()}),C.on("error",(A)=>{F(Error(`ffprobe error: ${A.message}`))}),C.on("close",(A)=>{if(A!==0){F(Error(`ffprobe failed with exit code ${A}`));return}try{let B=JSON.parse(E),q=B.streams.find((R)=>R.width!==void 0),Q=B.streams.find((R)=>R.bit_rate!==void 0&&R.width===void 0),Z=B.format,[L,K]=q.r_frame_rate.split("/").map(Number),X=L/K,G=parseFloat(q.duration||Z.duration||"0"),Y=Q?.bit_rate?Math.round(parseInt(Q.bit_rate)/1000):void 0;D({width:q.width,height:q.height,duration:G,fps:X,codec:q.codec_name,audioBitrate:Y})}catch(B){F(Error(`Failed to parse ffprobe output: ${B}`))}})})}function v(u,D=256){if(!u)return`${D}k`;let F=Math.min(u,D);if(F<=64)return"64k";if(F<=96)return"96k";if(F<=128)return"128k";if(F<=192)return"192k";return"256k"}function h(u){let D=Math.floor(u/3600),F=Math.floor(u%3600/60),C=u%60;return`${String(D).padStart(2,"0")}:${String(F).padStart(2,"0")}:${C.toFixed(3).padStart(6,"0")}`}import{mkdir as Ju,exists as Ku}from"node:fs/promises";async function P(u){if(!await Ku(u))await Ju(u,{recursive:!0})}var ZD=[{name:"1080p",width:1920,height:1080,videoBitrate:"5000k",audioBitrate:"256k"},{name:"720p",width:1280,height:720,videoBitrate:"3000k",audioBitrate:"256k"},{name:"480p",width:854,height:480,videoBitrate:"1500k",audioBitrate:"256k"},{name:"360p",width:640,height:360,videoBitrate:"800k",audioBitrate:"256k"}];function d(u,D){return ZD.filter((F)=>{return F.width<=u&&F.height<=D})}import{join as W}from"node:path";import{readdir as Gu,unlink as LD,rmdir as Iu}from"node:fs/promises";async function QD(u,D,F,C){let{width:E,height:A,interval:B,columns:q}=C,Q=W(D,".thumbnails_temp");await Bun.write(W(Q,".keep"),"");let Z=W(Q,"thumb_%04d.jpg");await z(["-i",u,"-vf",`fps=1/${B},scale=${E}:${A}`,"-q:v","5",Z]);let K=(await Gu(Q)).filter((x)=>x.startsWith("thumb_")&&x.endsWith(".jpg")).sort();if(K.length===0)throw Error("No thumbnails generated");let X=K.length,G=Math.ceil(X/q),Y=W(D,"thumbnails.jpg"),R=`tile=${q}x${G}`;await z(["-i",Z,"-filter_complex",R,"-q:v","5",Y]);let $=W(D,"thumbnails.vtt"),j=Ru(X,B,E,A,q,"thumbnails.jpg");await Bun.write($,j);for(let x of K)await LD(W(Q,x));return await LD(W(Q,".keep")),await Iu(Q),{spritePath:Y,vttPath:$}}function Ru(u,D,F,C,E,A){let B=`WEBVTT +import{createRequire as Mu}from"node:module";var Vu=Object.create;var{getPrototypeOf:yu,defineProperty:RD,getOwnPropertyNames:xu}=Object;var zu=Object.prototype.hasOwnProperty;var s=(u,D,F)=>{F=u!=null?Vu(yu(u)):{};let C=D||!u||!u.__esModule?RD(F,"default",{value:u,enumerable:!0}):F;for(let E of xu(u))if(!zu.call(C,E))RD(C,E,{get:()=>u[E],enumerable:!0});return C};var I=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var v=Mu(import.meta.url);var OD=I((EC,jD)=>{class wD{constructor(u,D,F){this.etaBufferLength=u||100,this.valueBuffer=[F],this.timeBuffer=[D],this.eta="0"}update(u,D,F){this.valueBuffer.push(D),this.timeBuffer.push(u),this.calculate(F-D)}getTime(){return this.eta}calculate(u){let D=this.valueBuffer.length,F=Math.min(this.etaBufferLength,D),C=this.valueBuffer[D-1]-this.valueBuffer[D-F],E=this.timeBuffer[D-1]-this.timeBuffer[D-F],A=C/E;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let B=Math.ceil(u/A/1000);if(isNaN(B))this.eta="NULL";else if(!isFinite(B))this.eta="INF";else if(B>1e7)this.eta="INF";else if(B<0)this.eta=0;else this.eta=B}}jD.exports=wD});var e=I((BC,SD)=>{var w=v("readline");class TD{constructor(u){this.stream=u,this.linewrap=!0,this.dy=0}cursorSave(){if(!this.stream.isTTY)return;this.stream.write("\x1B7")}cursorRestore(){if(!this.stream.isTTY)return;this.stream.write("\x1B8")}cursor(u){if(!this.stream.isTTY)return;if(u)this.stream.write("\x1B[?25h");else this.stream.write("\x1B[?25l")}cursorTo(u=null,D=null){if(!this.stream.isTTY)return;w.cursorTo(this.stream,u,D)}cursorRelative(u=null,D=null){if(!this.stream.isTTY)return;this.dy=this.dy+D,w.moveCursor(this.stream,u,D)}cursorRelativeReset(){if(!this.stream.isTTY)return;w.moveCursor(this.stream,0,-this.dy),w.cursorTo(this.stream,0,null),this.dy=0}clearRight(){if(!this.stream.isTTY)return;w.clearLine(this.stream,1)}clearLine(){if(!this.stream.isTTY)return;w.clearLine(this.stream,0)}clearBottom(){if(!this.stream.isTTY)return;w.clearScreenDown(this.stream)}newline(){this.stream.write(` +`),this.dy++}write(u,D=!1){if(this.linewrap===!0&&D===!1)this.stream.write(u.substr(0,this.getWidth()));else this.stream.write(u)}lineWrapping(u){if(!this.stream.isTTY)return;if(this.linewrap=u,u)this.stream.write("\x1B[?7h");else this.stream.write("\x1B[?7l")}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}}SD.exports=TD});var vD=I((AC,bD)=>{bD.exports=({onlyFirst:u=!1}={})=>{let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}});var PD=I((qC,hD)=>{var nu=vD();hD.exports=(u)=>typeof u==="string"?u.replace(nu(),""):u});var gD=I((ZC,DD)=>{var fD=(u)=>{if(Number.isNaN(u))return!1;if(u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141))return!0;return!1};DD.exports=fD;DD.exports.default=fD});var mD=I((QC,cD)=>{cD.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var lD=I((XC,uD)=>{var pu=PD(),au=gD(),su=mD(),dD=(u)=>{if(typeof u!=="string"||u.length===0)return 0;if(u=pu(u),u.length===0)return 0;u=u.replace(su()," ");let D=0;for(let F=0;F=127&&C<=159)continue;if(C>=768&&C<=879)continue;if(C>65535)F++;D+=au(C)?2:1}return D};uD.exports=dD;uD.exports.default=dD});var FD=I((YC,nD)=>{nD.exports=function(D,F,C){if(F.autopadding!==!0)return D;function E(A,B){return(F.autopaddingChar+A).slice(-B)}switch(C){case"percentage":return E(D,3);default:return D}}});var CD=I((JC,pD)=>{pD.exports=function(D,F){let C=Math.round(D*F.barsize),E=F.barsize-C;return F.barCompleteString.substr(0,C)+F.barGlue+F.barIncompleteString.substr(0,E)}});var ED=I((KC,aD)=>{aD.exports=function(D,F,C){function E(B){if(C)return C*Math.round(B/C);else return B}function A(B){return(F.autopaddingChar+B).slice(-2)}if(D>3600)return A(Math.floor(D/3600))+"h"+A(E(D%3600/60))+"m";else if(D>60)return A(Math.floor(D/60))+"m"+A(E(D%60))+"s";else if(D>10)return A(E(D))+"s";else return A(D)+"s"}});var BD=I((LC,sD)=>{var ru=lD(),iu=FD(),ou=CD(),tu=ED();sD.exports=function(D,F,C){let E=D.format,A=D.formatTime||tu,B=D.formatValue||iu,q=D.formatBar||ou,Q=Math.floor(F.progress*100)+"",J=F.stopTime||Date.now(),L=Math.round((J-F.startTime)/1000),G=Object.assign({},C,{bar:q(F.progress,D),percentage:B(Q,D,"percentage"),total:B(F.total,D,"total"),value:B(F.value,D,"value"),eta:B(F.eta,D,"eta"),eta_formatted:A(F.eta,D,5),duration:B(L,D,"duration"),duration_formatted:A(L,D,1)});E=E.replace(/\{(\w+)\}/g,function(Z,R){if(typeof G[R]<"u")return G[R];return Z});let X=Math.max(0,F.maxWidth-ru(E)-2),Y=Math.floor(X/2);switch(D.align){case"right":E=X>0?" ".repeat(X)+E:E;break;case"center":E=Y>0?" ".repeat(Y)+E:E;break;case"left":default:break}return E}});var d=I((GC,rD)=>{function K(u,D){if(typeof u>"u"||u===null)return D;else return u}rD.exports={parse:function(D,F){let C={},E=Object.assign({},F,D);return C.throttleTime=1000/K(E.fps,10),C.stream=K(E.stream,process.stderr),C.terminal=K(E.terminal,null),C.clearOnComplete=K(E.clearOnComplete,!1),C.stopOnComplete=K(E.stopOnComplete,!1),C.barsize=K(E.barsize,40),C.align=K(E.align,"left"),C.hideCursor=K(E.hideCursor,!1),C.linewrap=K(E.linewrap,!1),C.barGlue=K(E.barGlue,""),C.barCompleteChar=K(E.barCompleteChar,"="),C.barIncompleteChar=K(E.barIncompleteChar,"-"),C.format=K(E.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),C.formatTime=K(E.formatTime,null),C.formatValue=K(E.formatValue,null),C.formatBar=K(E.formatBar,null),C.etaBufferLength=K(E.etaBuffer,10),C.etaAsynchronousUpdate=K(E.etaAsynchronousUpdate,!1),C.progressCalculationRelative=K(E.progressCalculationRelative,!1),C.synchronousUpdate=K(E.synchronousUpdate,!0),C.noTTYOutput=K(E.noTTYOutput,!1),C.notTTYSchedule=K(E.notTTYSchedule,2000),C.emptyOnZero=K(E.emptyOnZero,!1),C.forceRedraw=K(E.forceRedraw,!1),C.autopadding=K(E.autopadding,!1),C.gracefulExit=K(E.gracefulExit,!1),C},assignDerivedOptions:function(D){return D.barCompleteString=D.barCompleteChar.repeat(D.barsize+1),D.barIncompleteString=D.barIncompleteChar.repeat(D.barsize+1),D.autopaddingChar=D.autopadding?K(D.autopaddingChar," "):"",D}}});var AD=I((IC,oD)=>{var iD=OD(),eu=e(),DF=BD(),uF=d(),FF=v("events");oD.exports=class extends FF{constructor(D){super();this.options=uF.assignDerivedOptions(D),this.terminal=this.options.terminal?this.options.terminal:new eu(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new iD(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format==="function"?this.options.format:DF}render(D=!1){let F={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};if(this.options.etaAsynchronousUpdate)this.updateETA();let C=this.formatter(this.options,F,this.payload);if(D||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=C)this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(C),this.terminal.clearRight(),this.lastDrawnString=C,this.lastRedraw=Date.now(),this.emit("redraw-post")}start(D,F,C){this.value=F||0,this.total=typeof D<"u"&&D>=0?D:100,this.startValue=F||0,this.payload=C||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new iD(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",D,F)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(D,F={}){if(typeof D==="number")this.value=D,this.eta.update(Date.now(),D,this.total);let C=(typeof D==="object"?D:F)||{};this.emit("update",this.total,this.value);for(let E in C)this.payload[E]=C[E];if(this.value>=this.getTotal()&&this.options.stopOnComplete)this.stop()}getProgress(){let D=this.value/this.total;if(this.options.progressCalculationRelative)D=(this.value-this.startValue)/(this.total-this.startValue);if(isNaN(D))D=this.options&&this.options.emptyOnZero?0:1;return D=Math.min(Math.max(D,0),1),D}increment(D=1,F={}){if(typeof D==="object")this.update(this.value+1,D);else this.update(this.value+D,F)}getTotal(){return this.total}setTotal(D){if(typeof D<"u"&&D>=0)this.total=D}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var eD=I((RC,tD)=>{var CF=AD(),EF=d();tD.exports=class extends CF{constructor(D,F){super(EF.parse(D,F));if(this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.options.synchronousUpdate=!1;this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline();this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(D,F){if(!this.timer)return;if(super.update(D,F),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2{var BF=e(),AF=AD(),qF=d(),ZF=v("events");Du.exports=class extends ZF{constructor(D,F){super();this.bars=[],this.options=qF.parse(D,F),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new BF(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(D,F,C,E={}){let A=new AF(Object.assign({},this.options,{terminal:this.terminal},E));if(this.bars.push(A),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return A;if(this.sigintCallback===null&&this.options.gracefulExit)this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback);if(!this.isActive){if(this.options.hideCursor===!0)this.terminal.cursor(!1);if(this.options.linewrap===!1)this.terminal.lineWrapping(!1);this.timer=setTimeout(this.update.bind(this),this.schedulingRate)}return this.isActive=!0,A.start(D,F,C),this.emit("start"),A}remove(D){let F=this.bars.indexOf(D);if(F<0)return!1;return this.bars.splice(F,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0}update(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0){this.terminal.clearLine();while(this.loggingBuffer.length>0)this.terminal.write(this.loggingBuffer.shift(),!0)}for(let D=0;D0)this.terminal.newline();this.bars[D].render()}if(this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline(),this.terminal.newline();if(this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find((D)=>D.isActive))this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback)process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null;if(this.isActive=!1,this.options.hideCursor===!0)this.terminal.cursor(!0);if(this.options.linewrap===!1)this.terminal.lineWrapping(!0);if(this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let D=0;D0)this.terminal.newline();this.bars[D].render(),this.bars[D].stop()}this.terminal.newline()}this.emit("stop")}log(D){this.loggingBuffer.push(D)}}});var Cu=I((UC,Fu)=>{Fu.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var Bu=I((kC,Eu)=>{Eu.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var qu=I((_C,Au)=>{Au.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var Qu=I((HC,Zu)=>{Zu.exports={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "}});var Yu=I((WC,Xu)=>{var QF=Cu(),XF=Bu(),YF=qu(),JF=Qu();Xu.exports={legacy:QF,shades_classic:XF,shades_grey:YF,rect:JF}});var Lu=I((VC,Ku)=>{var Ju=eD(),KF=uu(),LF=Yu(),GF=BD(),IF=FD(),RF=CD(),$F=ED();Ku.exports={Bar:Ju,SingleBar:Ju,MultiBar:KF,Presets:LF,Format:{Formatter:GF,BarFormat:RF,ValueFormat:IF,TimeFormat:$F}}});import{join as MD,basename as cu,extname as mu}from"node:path";import{randomUUID as du}from"node:crypto";import{rm as ND}from"node:fs/promises";import{spawn as h}from"node:child_process";async function j(){return new Promise((u)=>{let D=h("ffmpeg",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function O(){return new Promise((u)=>{let D=h("MP4Box",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function T(){return new Promise((u)=>{let D=h("ffmpeg",["-hide_banner","-encoders"]),F="";D.stdout.on("data",(C)=>{F+=C.toString()}),D.on("error",()=>u(!1)),D.on("close",(C)=>{if(C!==0)u(!1);else u(F.includes("h264_nvenc")||F.includes("hevc_nvenc"))})})}async function M(u,D,F){return new Promise((C,E)=>{let A=h("ffmpeg",u),B="";A.stderr.on("data",(q)=>{let Q=q.toString();if(B+=Q,D&&F){let J=Q.match(/time=(\d{2}):(\d{2}):(\d{2}\.\d{2})/);if(J){let L=parseInt(J[1]),G=parseInt(J[2]),X=parseFloat(J[3]),Y=L*3600+G*60+X,Z=Math.min(100,Y/F*100);D(Z)}}}),A.on("error",(q)=>{E(Error(`FFmpeg error: ${q.message}`))}),A.on("close",(q)=>{if(q===0)C();else E(Error(`FFmpeg failed with exit code ${q} +${B}`))})})}async function r(u){return new Promise((D,F)=>{let C=h("MP4Box",u),E="",A="";C.stdout.on("data",(B)=>{E+=B.toString()}),C.stderr.on("data",(B)=>{A+=B.toString()}),C.on("error",(B)=>{F(Error(`MP4Box error: ${B.message}`))}),C.on("close",(B)=>{if(B===0)D();else F(Error(`MP4Box failed with exit code ${B} +${A||E}`))})})}import{spawn as Nu}from"node:child_process";async function S(u){return new Promise((D,F)=>{let C=Nu("ffprobe",["-v","error","-show_entries","stream=width,height,duration,r_frame_rate,codec_name,codec_type,bit_rate","-show_entries","format=duration","-of","json",u]),E="";C.stdout.on("data",(A)=>{E+=A.toString()}),C.on("error",(A)=>{F(Error(`ffprobe error: ${A.message}`))}),C.on("close",(A)=>{if(A!==0){F(Error(`ffprobe failed with exit code ${A}`));return}try{let B=JSON.parse(E),q=B.streams.find((Z)=>Z.codec_type==="video"),Q=B.streams.find((Z)=>Z.codec_type==="audio"&&Z.bit_rate),J=B.format;if(!q){F(Error("No video stream found in input file"));return}let L=30;if(q.r_frame_rate){let[Z,R]=q.r_frame_rate.split("/").map(Number);if(Z&&R&&R!==0)L=Z/R}let G=parseFloat(q.duration||J.duration||"0"),X=Q?.bit_rate?Math.round(parseInt(Q.bit_rate)/1000):void 0,Y=q.bit_rate?Math.round(parseInt(q.bit_rate)/1000):void 0;D({width:q.width,height:q.height,duration:G,fps:L,codec:q.codec_name,audioBitrate:X,videoBitrate:Y})}catch(B){F(Error(`Failed to parse ffprobe output: ${B}`))}})})}function g(u,D=256){if(!u)return`${D}k`;let F=Math.min(u,D);if(F<=64)return"64k";if(F<=96)return"96k";if(F<=128)return"128k";if(F<=192)return"192k";return"256k"}function c(u){let D=Math.floor(u/3600),F=Math.floor(u%3600/60),C=u%60;return`${String(D).padStart(2,"0")}:${String(F).padStart(2,"0")}:${C.toFixed(3).padStart(6,"0")}`}import{mkdir as wu,access as ju,constants as Ou}from"node:fs/promises";async function b(u){try{await ju(u,Ou.F_OK)}catch{await wu(u,{recursive:!0})}}function Tu(u,D){let F=u*D;if(F<=230400)return 0.08;if(F<=409920)return 0.075;if(F<=921600)return 0.07;if(F<=2073600)return 0.065;if(F<=3686400)return 0.06;return 0.055}function x(u,D,F=30,C){let E=Tu(u,D),A=Math.round(u*D*F*E/1000);if(C&&A>C)A=C;return`${A}k`}var i=[{name:"360p",width:640,height:360,videoBitrate:x(640,360,30),audioBitrate:"192k"},{name:"480p",width:854,height:480,videoBitrate:x(854,480,30),audioBitrate:"192k"},{name:"720p",width:1280,height:720,videoBitrate:x(1280,720,30),audioBitrate:"192k"},{name:"1080p",width:1920,height:1080,videoBitrate:x(1920,1080,30),audioBitrate:"256k"},{name:"1440p",width:2560,height:1440,videoBitrate:x(2560,1440,30),audioBitrate:"256k"},{name:"2160p",width:3840,height:2160,videoBitrate:x(3840,2160,30),audioBitrate:"256k"}];function o(u,D,F=30,C){let E=[],A=i.filter((B)=>{return B.width<=u&&B.height<=D});for(let B of A)E.push({...B,videoBitrate:x(B.width,B.height,30,C)});if(F>=45)for(let B of A)E.push(m(B,60,C));if(F>=75)for(let B of A)E.push(m(B,90,C));if(F>=95)for(let B of A)E.push(m(B,120,C));return E}function m(u,D,F){return{...u,name:`${u.name}-${D}`,videoBitrate:x(u.width,u.height,D,F)}}function $D(u){let F=u.trim().match(/^(\d+)p?(?:[@-](\d+))?$/i);if(!F)return null;let C=F[1]+"p",E=F[2]?parseInt(F[2]):30;return{resolution:C,fps:E}}function UD(u,D=30,F){let C=i.find((E)=>E.name===u);if(!C)return null;if(D===30)return{...C,videoBitrate:x(C.width,C.height,30,F)};return m(C,D,F)}function Su(u,D,F,C){let E=$D(u);if(!E)return`Invalid profile format: ${u}. Use format like: 360, 720@60, 1080-60`;let A=UD(E.resolution,E.fps);if(!A)return`Unknown resolution: ${E.resolution}. Available: 360, 480, 720, 1080, 1440, 2160`;if(A.width>D||A.height>F)return`Source resolution (${D}x${F}) is lower than ${u} (${A.width}x${A.height})`;if(E.fps>C)return`Source FPS (${C}) is lower than requested ${E.fps} FPS in ${u}`;return null}function kD(u,D,F,C,E){let A=[],B=[];for(let q of u){let Q=Su(q,D,F,C);if(Q){B.push(Q);continue}let J=$D(q);if(!J)continue;let L=UD(J.resolution,J.fps,E);if(L)A.push(L)}return{profiles:A,errors:B}}import{join as z}from"node:path";import{readdir as bu,unlink as _D,rmdir as vu,writeFile as HD}from"node:fs/promises";async function WD(u,D,F="00:00:01"){let C=z(D,"poster.jpg"),E=/^\d+(\.\d+)?$/.test(F)?F:F;return await M(["-ss",E,"-i",u,"-vframes","1","-q:v","2","-y",C]),C}async function VD(u,D,F,C){let{width:E,height:A,interval:B,columns:q}=C,Q=z(D,".thumbnails_temp");await b(Q),await HD(z(Q,".keep"),"");let J=z(Q,"thumb_%04d.jpg");await M(["-i",u,"-vf",`fps=1/${B},scale=${E}:${A}`,"-q:v","5",J]);let G=(await bu(Q)).filter((_)=>_.startsWith("thumb_")&&_.endsWith(".jpg")).sort();if(G.length===0)throw Error("No thumbnails generated");let X=G.length,Y=Math.ceil(X/q),Z=z(D,"thumbnails.jpg"),R=`tile=${q}x${Y}`;await M(["-i",J,"-filter_complex",R,"-q:v","5",Z]);let U=z(D,"thumbnails.vtt"),$=hu(X,B,E,A,q,"thumbnails.jpg");await HD(U,$);for(let _ of G)await _D(z(Q,_));return await _D(z(Q,".keep")),await vu(Q),{spritePath:Z,vttPath:U}}function hu(u,D,F,C,E,A){let B=`WEBVTT -`;for(let q=0;q ${h(Z)} -`,B+=`${A}#xywh=${X},${G},${F},${C} +`;for(let q=0;q ${c(J)} +`,B+=`${A}#xywh=${X},${Y},${F},${C} -`}return B}import{join as $u}from"node:path";async function XD(u,D,F,C,E,A,B,q,Q,Z,L){let K=$u(D,`video_${F.name}.mp4`),X=["-y","-i",u,"-c:v",C];if(C==="h264_nvenc")X.push("-rc:v","vbr"),X.push("-preset",E),X.push("-2pass","0");else X.push("-preset",E);X.push("-b:v",F.videoBitrate,"-maxrate",F.videoBitrate,"-bufsize",`${parseInt(F.videoBitrate)*2}k`);let G=Math.round(q*B);X.push("-g",String(G),"-keyint_min",String(G),"-sc_threshold","0");let Y=[`scale=${F.width}:${F.height}`];if(Z){if(Z.deinterlace)Y.push("yadif");if(Z.denoise)Y.push("hqdn3d");if(Z.customFilters)Y.push(...Z.customFilters)}X.push("-vf",Y.join(","));let R=parseInt(F.audioBitrate)||256,$=v(Q,R);if(X.push("-c:a","aac","-b:a",$),Z?.audioNormalize)X.push("-af","loudnorm");return X.push("-f","mp4",K),await z(X,L,A),K}async function YD(u,D,F,C,E,A,B,q,Q,Z,L,K,X){let G=new Map;if(Z&&F.length>1)for(let Y=0;YXD(u,D,x,C,E,A,B,q,Q,K,(S)=>{if(X)X(x.name,S)}));(await Promise.all($)).forEach((x,S)=>{let T=R[S];G.set(T.name,x)})}else for(let Y of F){let R=await XD(u,D,Y,C,E,A,B,q,Q,K,($)=>{if(X)X(Y.name,$)});G.set(Y.name,R)}return G}import{join as _}from"node:path";async function JD(u,D,F,C){let E=_(D,"manifest.mpd"),A=["-dash",String(C*1000),"-frag",String(C*1000),"-rap","-segment-name","$RepresentationID$_$Number$","-out",E];for(let B of F){let q=u.get(B.name);if(!q)throw Error(`MP4 file not found for profile: ${B.name}`);if(A.push(`${q}#video:id=${B.name}`),B===F[0])A.push(`${q}#audio:id=audio`)}return await m(A),await xu(D,F),await Hu(E,F),E}async function xu(u,D){let{readdir:F,rename:C,mkdir:E}=await import("node:fs/promises");for(let q of D){let Q=_(u,q.name);await E(Q,{recursive:!0})}let A=_(u,"audio");await E(A,{recursive:!0});let B=await F(u);for(let q of B){if(q==="manifest.mpd")continue;if(q.startsWith("audio_")||q==="audio_init.m4s"){let Q=_(u,q),Z=_(A,q);await C(Q,Z);continue}for(let Q of D)if(q.startsWith(`${Q.name}_`)){let Z=_(u,q),L=_(u,Q.name,q);await C(Z,L);break}}}async function Hu(u,D){let{readFile:F,writeFile:C}=await import("node:fs/promises"),E=await F(u,"utf-8");E=E.replace(/media="\$RepresentationID\$_\$Number\$\.m4s"/g,'media="$RepresentationID$/$RepresentationID$_$Number$.m4s"'),E=E.replace(/initialization="\$RepresentationID\$_\.mp4"/g,'initialization="$RepresentationID$/$RepresentationID$_.mp4"'),await C(u,E,"utf-8")}async function l(u){let{input:D,outputDir:F,segmentDuration:C=2,profiles:E,useNvenc:A,generateThumbnails:B=!0,thumbnailConfig:q={},parallel:Q=!0,onProgress:Z}=u,L=KD("/tmp",`dash-converter-${_u()}`);await P(L);try{return await yu(D,F,L,C,E,A,B,q,Q,Z)}finally{try{await ku(L,{recursive:!0,force:!0})}catch(K){console.warn(`Warning: Failed to cleanup temp directory: ${L}`)}}}async function yu(u,D,F,C,E,A,B,q,Q,Z){if(!await y())throw Error("FFmpeg is not installed or not in PATH");if(!await V())throw Error("MP4Box is not installed or not in PATH. Install gpac package.");let L=(H,U,BD,O)=>{if(Z)Z({stage:H,percent:U,message:BD,currentProfile:O})};L("analyzing",0,"Analyzing input video...");let K=await b(u),X=A!==!1?await M():!1,G=A===!0?!0:A===!1?!1:X;if(A===!0&&!X)throw Error("NVENC requested but not available. Check NVIDIA drivers and GPU support.");let Y=E||d(K.width,K.height);if(Y.length===0)throw Error("No suitable profiles found for input video resolution");let R=Uu(u,Wu(u)),$=KD(D,R);await P($),L("analyzing",20,`Using ${G?"NVENC":"CPU"} encoding`,void 0);let j=G?"h264_nvenc":"libx264",x=G?"p4":"medium",S=G?3:2;L("encoding",25,`Stage 1: Encoding ${Y.length} profiles to MP4...`);let T=await YD(u,F,Y,j,x,K.duration,C,K.fps||25,K.audioBitrate,Q,S,void 0,(H,U)=>{let O=25+Y.findIndex((Au)=>Au.name===H)/Y.length*40,AD=U/100*(40/Y.length);if(L("encoding",O+AD,`Encoding ${H}...`,H),Z)Z({stage:"encoding",percent:O+AD,currentProfile:H,profilePercent:U,message:`Encoding ${H}...`})});L("encoding",65,"Stage 1 complete: All profiles encoded"),L("encoding",70,"Stage 2: Creating DASH with MP4Box...");let Eu=await JD(T,$,Y,C),Bu=Array.from(T.values());L("encoding",80,"Stage 2 complete: DASH created");let CD,ED;if(B){L("thumbnails",80,"Generating thumbnail sprites...");let H={width:q.width||160,height:q.height||90,interval:q.interval||1,columns:q.columns||10},U=await QD(u,$,K.duration,H);CD=U.spritePath,ED=U.vttPath,L("thumbnails",90,"Thumbnails generated")}return L("manifest",95,"Finalizing manifest..."),L("complete",100,"Conversion complete!"),{manifestPath:Eu,videoPaths:Bu,thumbnailSpritePath:CD,thumbnailVttPath:ED,duration:K.duration,profiles:Y,usedNvenc:G}}var uD=g(oD(),1),FD=process.argv[2],Du=process.argv[3]||"./output";if(!FD)console.error("❌ Usage: bun run test.ts [output-dir]"),process.exit(1);console.log(`\uD83D\uDD0D Checking system... -`);var uu=await y(),Fu=await M(),Cu=await V();console.log(`FFmpeg: ${uu?"✅":"❌"}`);console.log(`NVENC: ${Fu?"✅ (GPU acceleration)":"⚠️ (CPU only)"}`);console.log(`MP4Box: ${Cu?"✅":"❌"} -`);if(!uu)console.error("❌ FFmpeg not found. Please install FFmpeg first."),process.exit(1);if(!Cu)console.error("❌ MP4Box not found. Please install: sudo pacman -S gpac"),process.exit(1);console.log(`\uD83D\uDCF9 Input: ${FD}`);console.log(`\uD83D\uDCC1 Output: ${Du} -`);console.log(`\uD83D\uDE80 Starting conversion... -`);var c=new uD.default.MultiBar({format:"{stage} | {bar} | {percentage}% | {name}",barCompleteChar:"█",barIncompleteChar:"░",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},uD.default.Presets.shades_classic),o={},DD=null;try{let u=await l({input:FD,outputDir:Du,segmentDuration:2,useNvenc:Fu,generateThumbnails:!0,parallel:!0,onProgress:(D)=>{let F=D.stage==="encoding"?"Encoding":D.stage==="thumbnails"?"Thumbnails":D.stage==="manifest"?"Manifest":D.stage==="analyzing"?"Analyzing":"Complete";if(D.stage==="encoding"&&D.currentProfile){if(!o[D.currentProfile])o[D.currentProfile]=c.create(100,0,{stage:"Encode",name:D.currentProfile});let C=D.profilePercent??D.percent;o[D.currentProfile].update(C,{stage:"Encode",name:D.currentProfile})}if(!DD)DD=c.create(100,0,{stage:F,name:"Overall"});DD.update(D.percent,{stage:F,name:D.message||"Overall"})}});if(c.stop(),console.log(` +`}return B}import{join as Pu}from"node:path";async function yD(u,D,F,C,E,A,B,q,Q,J,L){let G=Pu(D,`video_${F.name}.mp4`),X=["-y","-i",u,"-c:v",C];if(C==="h264_nvenc")X.push("-rc:v","vbr"),X.push("-preset",E),X.push("-2pass","0");else X.push("-preset",E);X.push("-b:v",F.videoBitrate,"-maxrate",F.videoBitrate,"-bufsize",`${parseInt(F.videoBitrate)*2}k`);let Y=Math.round(q*B);X.push("-g",String(Y),"-keyint_min",String(Y),"-sc_threshold","0");let Z=[`scale=${F.width}:${F.height}`];if(J){if(J.deinterlace)Z.push("yadif");if(J.denoise)Z.push("hqdn3d");if(J.customFilters)Z.push(...J.customFilters)}X.push("-vf",Z.join(","));let R=parseInt(F.audioBitrate)||256,U=g(Q,R);if(X.push("-c:a","aac","-b:a",U),J?.audioNormalize)X.push("-af","loudnorm");return X.push("-f","mp4",G),await M(X,L,A),G}async function xD(u,D,F,C,E,A,B,q,Q,J,L,G,X){let Y=new Map;if(J&&F.length>1)for(let Z=0;ZyD(u,D,_,C,E,A,B,q,Q,G,(V)=>{if(X)X(_.name,V)}));(await Promise.all(U)).forEach((_,V)=>{let a=R[V];Y.set(a.name,_)})}else for(let Z of F){let R=await yD(u,D,Z,C,E,A,B,q,Q,G,(U)=>{if(X)X(Z.name,U)});Y.set(Z.name,R)}return Y}import{join as N}from"node:path";async function zD(u,D,F,C){let E=N(D,"manifest.mpd"),A=["-dash",String(C*1000),"-frag",String(C*1000),"-rap","-segment-name","$RepresentationID$_$Number$","-out",E];for(let B of F){let q=u.get(B.name);if(!q)throw Error(`MP4 file not found for profile: ${B.name}`);if(A.push(`${q}#video:id=${B.name}`),B===F[0])A.push(`${q}#audio:id=audio`)}return await r(A),await fu(D,F),await gu(E,F),E}async function fu(u,D){let{readdir:F,rename:C,mkdir:E}=await import("node:fs/promises");for(let q of D){let Q=N(u,q.name);await E(Q,{recursive:!0})}let A=N(u,"audio");await E(A,{recursive:!0});let B=await F(u);for(let q of B){if(q==="manifest.mpd")continue;if(q.startsWith("audio_")||q==="audio_init.m4s"){let Q=N(u,q),J=N(A,q);await C(Q,J);continue}for(let Q of D)if(q.startsWith(`${Q.name}_`)){let J=N(u,q),L=N(u,Q.name,q);await C(J,L);break}}}async function gu(u,D){let{readFile:F,writeFile:C}=await import("node:fs/promises"),E=await F(u,"utf-8");E=E.replace(/media="\$RepresentationID\$_\$Number\$\.m4s"/g,'media="$RepresentationID$/$RepresentationID$_$Number$.m4s"'),E=E.replace(/initialization="\$RepresentationID\$_\.mp4"/g,'initialization="$RepresentationID$/$RepresentationID$_.mp4"'),await C(u,E,"utf-8")}async function t(u){let{input:D,outputDir:F,segmentDuration:C=2,profiles:E,customProfiles:A,useNvenc:B,generateThumbnails:q=!0,thumbnailConfig:Q={},generatePoster:J=!0,posterTimecode:L="00:00:01",parallel:G=!0,onProgress:X}=u,Y=MD("/tmp",`dash-converter-${du()}`);await b(Y);try{return await lu(D,F,Y,C,E,A,B,q,Q,J,L,G,X)}finally{try{await ND(Y,{recursive:!0,force:!0})}catch(Z){console.warn(`Warning: Failed to cleanup temp directory: ${Y}`)}}}async function lu(u,D,F,C,E,A,B,q,Q,J,L,G,X){if(!await j())throw Error("FFmpeg is not installed or not in PATH");if(!await O())throw Error("MP4Box is not installed or not in PATH. Install gpac package.");let Y=(k,y,GD,f)=>{if(X)X({stage:k,percent:y,message:GD,currentProfile:f})};Y("analyzing",0,"Analyzing input video...");let Z=await S(u),R=B!==!1?await T():!1,U=B===!0?!0:B===!1?!1:R;if(B===!0&&!R)throw Error("NVENC requested but not available. Check NVIDIA drivers and GPU support.");let $;if(A&&A.length>0){let k=kD(A,Z.width,Z.height,Z.fps,Z.videoBitrate);if(k.errors.length>0){console.warn(` +⚠️ Profile warnings:`);for(let y of k.errors)console.warn(` - ${y}`);console.warn("")}if($=k.profiles,$.length===0)throw Error("No valid profiles found in custom list. Check warnings above.")}else if(E)$=E;else $=o(Z.width,Z.height,Z.fps,Z.videoBitrate);if($.length===0)throw Error("No suitable profiles found for input video resolution");let _=cu(u,mu(u)),V=MD(D,_);try{await ND(V,{recursive:!0,force:!0})}catch(k){}await b(V),Y("analyzing",20,`Using ${U?"NVENC":"CPU"} encoding`,void 0);let a=U?"h264_nvenc":"libx264",Uu=U?"p4":"medium",ku=U?3:2;Y("encoding",25,`Stage 1: Encoding ${$.length} profiles to MP4...`);let YD=await xD(u,F,$,a,Uu,Z.duration,C,Z.fps||25,Z.audioBitrate,G,ku,void 0,(k,y)=>{let f=25+$.findIndex((Wu)=>Wu.name===k)/$.length*40,ID=y/100*(40/$.length);if(Y("encoding",f+ID,`Encoding ${k}...`,k),X)X({stage:"encoding",percent:f+ID,currentProfile:k,profilePercent:y,message:`Encoding ${k}...`})});Y("encoding",65,"Stage 1 complete: All profiles encoded"),Y("encoding",70,"Stage 2: Creating DASH with MP4Box...");let _u=await zD(YD,V,$,C),Hu=Array.from(YD.values());Y("encoding",80,"Stage 2 complete: DASH created");let JD,KD;if(q){Y("thumbnails",80,"Generating thumbnail sprites...");let k={width:Q.width||160,height:Q.height||90,interval:Q.interval||1,columns:Q.columns||10},y=await VD(u,V,Z.duration,k);JD=y.spritePath,KD=y.vttPath,Y("thumbnails",90,"Thumbnails generated")}let LD;if(J)Y("thumbnails",92,"Generating poster image..."),LD=await WD(u,V,L),Y("thumbnails",95,"Poster generated");return Y("manifest",95,"Finalizing manifest..."),Y("complete",100,"Conversion complete!"),{manifestPath:_u,videoPaths:Hu,thumbnailSpritePath:JD,thumbnailVttPath:KD,posterPath:LD,duration:Z.duration,profiles:$,usedNvenc:U}}var QD=s(Lu(),1);import{statSync as UF}from"node:fs";var H=process.argv.slice(2),n,p,XD=[];for(let u=0;uC.trim()).filter((C)=>C.length>0)}else if(H[u]==="-p"||H[u]==="--poster")p=H[u+1],u++;else if(!H[u].startsWith("-"))XD.push(H[u]);var P=XD[0],Gu=XD[1]||".";if(!P)console.error("❌ Usage: dvc-cli [output-dir] [-r resolutions] [-p poster-timecode]"),console.error(` +Examples:`),console.error(" dvc-cli video.mp4"),console.error(" dvc-cli video.mp4 ./output"),console.error(" dvc-cli video.mp4 -r 360,480,720"),console.error(" dvc-cli video.mp4 -r 720@60,1080@60,2160@60"),console.error(" dvc-cli video.mp4 -p 00:00:05"),console.error(" dvc-cli video.mp4 ./output -r 720,1080 -p 10"),process.exit(1);console.log(`\uD83D\uDD0D Checking system... +`);var Iu=await j(),Ru=await T(),$u=await O();console.log(`FFmpeg: ${Iu?"✅":"❌"}`);console.log(`NVENC: ${Ru?"✅ (GPU acceleration)":"⚠️ (CPU only)"}`);console.log(`MP4Box: ${$u?"✅":"❌"} +`);if(!Iu)console.error("❌ FFmpeg not found. Please install FFmpeg first."),process.exit(1);if(!$u)console.error("❌ MP4Box not found. Please install: sudo pacman -S gpac"),process.exit(1);console.log(`\uD83D\uDCCA Analyzing video... +`);var W=await S(P),kF=UF(P),_F=(kF.size/1048576).toFixed(2);console.log("\uD83D\uDCF9 Video Information:");console.log(` File: ${P}`);console.log(` Size: ${_F} MB`);console.log(` Resolution: ${W.width}x${W.height}`);console.log(` FPS: ${W.fps.toFixed(2)}`);console.log(` Duration: ${Math.floor(W.duration/60)}m ${Math.floor(W.duration%60)}s`);console.log(` Codec: ${W.codec}`);if(W.videoBitrate)console.log(` Video Bitrate: ${(W.videoBitrate/1000).toFixed(2)} Mbps`);if(W.audioBitrate)console.log(` Audio Bitrate: ${W.audioBitrate} kbps`);console.log(` +\uD83D\uDCC1 Output: ${Gu}`);if(n)console.log(`\uD83C\uDFAF Custom profiles: ${n.join(", ")}`);if(p)console.log(`\uD83D\uDDBC️ Poster timecode: ${p}`);console.log(` +\uD83D\uDE80 Starting conversion... +`);var l=new QD.default.MultiBar({format:"{stage} | {bar} | {percentage}% | {name}",barCompleteChar:"█",barIncompleteChar:"░",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},QD.default.Presets.shades_classic),qD={},ZD=null;try{let u=await t({input:P,outputDir:Gu,customProfiles:n,posterTimecode:p,segmentDuration:2,useNvenc:Ru,generateThumbnails:!0,generatePoster:!0,parallel:!0,onProgress:(D)=>{let F=D.stage==="encoding"?"Encoding":D.stage==="thumbnails"?"Thumbnails":D.stage==="manifest"?"Manifest":D.stage==="analyzing"?"Analyzing":"Complete";if(D.stage==="encoding"&&D.currentProfile){if(!qD[D.currentProfile])qD[D.currentProfile]=l.create(100,0,{stage:"Encode",name:D.currentProfile});let C=D.profilePercent??D.percent;qD[D.currentProfile].update(C,{stage:"Encode",name:D.currentProfile})}if(!ZD)ZD=l.create(100,0,{stage:F,name:"Overall"});ZD.update(D.percent,{stage:F,name:D.message||"Overall"})}});if(l.stop(),console.log(` ✅ Conversion completed successfully! -`),console.log("\uD83D\uDCCA Results:"),console.log(` Manifest: ${u.manifestPath}`),console.log(` Duration: ${u.duration.toFixed(2)}s`),console.log(` Profiles: ${u.profiles.map((D)=>D.name).join(", ")}`),console.log(` Encoder: ${u.usedNvenc?"⚡ NVENC (GPU)":"\uD83D\uDD27 libx264 (CPU)"}`),u.thumbnailSpritePath)console.log(` Thumbnails: ${u.thumbnailSpritePath}`),console.log(` VTT file: ${u.thumbnailVttPath}`);console.log(` -\uD83C\uDF89 Done! You can now use the manifest file in your video player.`)}catch(u){c.stop(),console.error(` +`),console.log("\uD83D\uDCCA Results:"),console.log(` Manifest: ${u.manifestPath}`),console.log(` Duration: ${u.duration.toFixed(2)}s`),console.log(` Profiles: ${u.profiles.map((D)=>D.name).join(", ")}`),console.log(` Encoder: ${u.usedNvenc?"⚡ NVENC (GPU)":"\uD83D\uDD27 libx264 (CPU)"}`),u.posterPath)console.log(` Poster: ${u.posterPath}`);if(u.thumbnailSpritePath)console.log(` Thumbnails: ${u.thumbnailSpritePath}`),console.log(` VTT file: ${u.thumbnailVttPath}`);console.log(` +\uD83C\uDF89 Done! You can now use the manifest file in your video player.`)}catch(u){l.stop(),console.error(` ❌ Error during conversion:`),console.error(u),process.exit(1)} diff --git a/package.json b/package.json index dd9fcf9..e81565e 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@grom13/dvc-cli", - "version": "0.1.0", + "version": "0.1.3", "description": "Fast DASH video converter with NVENC acceleration and thumbnail sprites", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", "bin": { - "dvc": "./bin/cli.js" + "dvc-cli": "./bin/cli.js" }, "exports": { ".": { @@ -44,12 +44,12 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/grom13/dvc-cli.git" + "url": "https://gromlab.ru/gromov/dvc-cli.git" }, "bugs": { - "url": "https://github.com/grom13/dvc-cli/issues" + "url": "https://gromlab.ru/gromov/dvc-cli/issues" }, - "homepage": "https://github.com/grom13/dvc-cli#readme", + "homepage": "https://gromlab.ru/gromov/dvc-cli#readme", "engines": { "node": ">=18.0.0" }, diff --git a/src/cli.ts b/src/cli.ts index 68e4c59..c04a7d0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -4,59 +4,64 @@ * DASH Video Converter CLI * * Usage: - * dvc [output-dir] + * dvc-cli [output-dir] [-r resolutions] [-p poster-timecode] * * Example: - * dvc ./video.mp4 ./output + * dvc-cli ./video.mp4 ./output -r 720,1080 */ import { convertToDash, checkFFmpeg, checkNvenc, checkMP4Box, getVideoMetadata } from './index'; import cliProgress from 'cli-progress'; import { statSync } from 'node:fs'; -const input = process.argv[2]; -const outputDir = process.argv[3] || '.'; // Текущая директория по умолчанию - -// Parse optional -r or --resolutions argument +// Parse arguments +const args = process.argv.slice(2); let customProfiles: string[] | undefined; let posterTimecode: string | undefined; +const positionalArgs: string[] = []; -for (let i = 4; i < process.argv.length; i++) { - if (process.argv[i] === '-r' || process.argv[i] === '--resolutions') { +// First pass: extract flags and their values +for (let i = 0; i < args.length; i++) { + if (args[i] === '-r' || args[i] === '--resolutions') { // Collect all arguments after -r until next flag or end const profilesArgs: string[] = []; - for (let j = i + 1; j < process.argv.length; j++) { + for (let j = i + 1; j < args.length; j++) { // Stop if we hit another flag (starts with -) - if (process.argv[j].startsWith('-')) { + if (args[j].startsWith('-')) { break; } - profilesArgs.push(process.argv[j]); + profilesArgs.push(args[j]); + i = j; // Skip these args in main loop } - // If there's only one arg, it might contain commas: "720,1080" - // If there are multiple args, they might be: "720" "1080" or "720," "1080" - // Solution: join with comma, then split by comma/space + // Parse profiles const joinedArgs = profilesArgs.join(','); customProfiles = joinedArgs .split(/[,\s]+/) // Split by comma or whitespace .map(s => s.trim()) .filter(s => s.length > 0); - } - - if (process.argv[i] === '-p' || process.argv[i] === '--poster') { - posterTimecode = process.argv[i + 1]; + } else if (args[i] === '-p' || args[i] === '--poster') { + posterTimecode = args[i + 1]; + i++; // Skip next arg + } else if (!args[i].startsWith('-')) { + // Positional argument + positionalArgs.push(args[i]); } } +// Extract positional arguments +const input = positionalArgs[0]; +const outputDir = positionalArgs[1] || '.'; // Текущая директория по умолчанию + if (!input) { - console.error('❌ Usage: dvc [output-dir] [-r resolutions] [-p poster-timecode]'); + console.error('❌ Usage: dvc-cli [output-dir] [-r resolutions] [-p poster-timecode]'); console.error('\nExamples:'); - console.error(' dvc video.mp4'); - console.error(' dvc video.mp4 ./output'); - console.error(' dvc video.mp4 -r 360,480,720'); - console.error(' dvc video.mp4 -r 720@60,1080@60,2160@60'); - console.error(' dvc video.mp4 -p 00:00:05'); - console.error(' dvc video.mp4 ./output -r 720,1080 -p 10'); + console.error(' dvc-cli video.mp4'); + console.error(' dvc-cli video.mp4 ./output'); + console.error(' dvc-cli video.mp4 -r 360,480,720'); + console.error(' dvc-cli video.mp4 -r 720@60,1080@60,2160@60'); + console.error(' dvc-cli video.mp4 -p 00:00:05'); + console.error(' dvc-cli video.mp4 ./output -r 720,1080 -p 10'); process.exit(1); } diff --git a/src/core/thumbnails.ts b/src/core/thumbnails.ts index 2a8c6a9..7fd9485 100644 --- a/src/core/thumbnails.ts +++ b/src/core/thumbnails.ts @@ -1,7 +1,7 @@ import { join } from 'node:path'; import type { ThumbnailConfig } from '../types'; -import { execFFmpeg, formatVttTime } from '../utils'; -import { exists, readdir, unlink, rmdir } from 'node:fs/promises'; +import { execFFmpeg, formatVttTime, ensureDir } from '../utils'; +import { readdir, unlink, rmdir, writeFile } from 'node:fs/promises'; /** * Generate poster image from video at specific timecode @@ -45,7 +45,8 @@ export async function generateThumbnailSprite( // Create temp directory for individual thumbnails const tempDir = join(outputDir, '.thumbnails_temp'); - await Bun.write(join(tempDir, '.keep'), ''); + await ensureDir(tempDir); + await writeFile(join(tempDir, '.keep'), ''); // Generate individual thumbnails const thumbnailPattern = join(tempDir, 'thumb_%04d.jpg'); @@ -95,7 +96,7 @@ export async function generateThumbnailSprite( 'thumbnails.jpg' ); - await Bun.write(vttPath, vttContent); + await writeFile(vttPath, vttContent); // Clean up temp files for (const file of thumbFiles) { diff --git a/src/utils/fs.ts b/src/utils/fs.ts index 0150518..7d5ab5f 100644 --- a/src/utils/fs.ts +++ b/src/utils/fs.ts @@ -1,10 +1,12 @@ -import { mkdir, exists } from 'node:fs/promises'; +import { mkdir, access, constants } from 'node:fs/promises'; /** * Ensure directory exists */ export async function ensureDir(dirPath: string): Promise { - if (!await exists(dirPath)) { + try { + await access(dirPath, constants.F_OK); + } catch { await mkdir(dirPath, { recursive: true }); } }