Files
create-vod/bin/cli.js

86 lines
53 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
import{createRequire as IF}from"node:module";var NF=Object.create;var{getPrototypeOf:zF,defineProperty:tD,getOwnPropertyNames:HF}=Object;var qF=Object.prototype.hasOwnProperty;var ED=(u,D,E)=>{E=u!=null?NF(zF(u)):{};let F=D||!u||!u.__esModule?tD(E,"default",{value:u,enumerable:!0}):E;for(let C of HF(u))if(!qF.call(F,C))tD(F,C,{get:()=>u[C],enumerable:!0});return F};var x=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var p=IF(import.meta.url);var Nu=x((z3,Qu)=>{class _u{constructor(u,D,E){this.etaBufferLength=u||100,this.valueBuffer=[E],this.timeBuffer=[D],this.eta="0"}update(u,D,E){this.valueBuffer.push(D),this.timeBuffer.push(u),this.calculate(E-D)}getTime(){return this.eta}calculate(u){let D=this.valueBuffer.length,E=Math.min(this.etaBufferLength,D),F=this.valueBuffer[D-1]-this.valueBuffer[D-E],C=this.timeBuffer[D-1]-this.timeBuffer[D-E],B=F/C;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let A=Math.ceil(u/B/1000);if(isNaN(A))this.eta="NULL";else if(!isFinite(A))this.eta="INF";else if(A>1e7)this.eta="INF";else if(A<0)this.eta=0;else this.eta=A}}Qu.exports=_u});var MD=x((H3,Hu)=>{var d=p("readline");class zu{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;d.cursorTo(this.stream,u,D)}cursorRelative(u=null,D=null){if(!this.stream.isTTY)return;this.dy=this.dy+D,d.moveCursor(this.stream,u,D)}cursorRelativeReset(){if(!this.stream.isTTY)return;d.moveCursor(this.stream,0,-this.dy),d.cursorTo(this.stream,0,null),this.dy=0}clearRight(){if(!this.stream.isTTY)return;d.clearLine(this.stream,1)}clearLine(){if(!this.stream.isTTY)return;d.clearLine(this.stream,0)}clearBottom(){if(!this.stream.isTTY)return;d.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)}}Hu.exports=zu});var Iu=x((q3,qu)=>{qu.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 Vu=x((I3,xu)=>{var pF=Iu();xu.exports=(u)=>typeof u==="string"?u.replace(pF(),""):u});var Mu=x((x3,OD)=>{var Lu=(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};OD.exports=Lu;OD.exports.default=Lu});var Ru=x((V3,Ou)=>{Ou.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 wu=x((L3,RD)=>{var nF=Vu(),sF=Mu(),aF=Ru(),ju=(u)=>{if(typeof u!=="string"||u.length===0)return 0;if(u=nF(u),u.length===0)return 0;u=u.replace(aF()," ");let D=0;for(let E=0;E<u.length;E++){let F=u.codePointAt(E);if(F<=31||F>=127&&F<=159)continue;if(F>=768&&F<=879)continue;if(F>65535)E++;D+=sF(F)?2:1}return D};RD.exports=ju;RD.exports.default=ju});var jD=x((M3,Su)=>{Su.exports=function(D,E,F){if(E.autopadding!==!0)return D;function C(B,A){return(E.autopaddingChar+B).slice(-A)}switch(F){case"percentage":return C(D,3);default:return D}}});var wD=x((O3,Tu)=>{Tu.exports=function(D,E){let F=Math.round(D*E.barsize),C=E.barsize-F;return E.barCompleteString.substr(0,F)+E.barGlue+E.barIncompleteString.substr(0,C)}});var SD=x((R3,bu)=>{bu.exports=function(D,E,F){function C(A){if(F)return F*Math.round(A/F);else return A}function B(A){return(E.autopaddingChar+A).slice(-2)}if(D>3600)return B(Math.floor(D/3600))+"h"+B(C(D%3600/60))+"m";else if(D>60)return B(Math.floor(D/60))+"m"+B(C(D%60))+"s";else if(D>10)return B(C(D))+"s";else return B(D)+"s"}});var TD=x((j3,yu)=>{var rF=wu(),iF=jD(),oF=wD(),tF=SD();yu.exports=function(D,E,F){let C=D.format,B=D.formatTime||tF,A=D.formatValue||iF,$=D.formatBar||oF,J=Math.floor(E.progress*100)+"",G=E.stopTime||Date.now(),X=Math.round((G-E.startTime)/1000),Y=Object.assign({},F,{bar:$(E.progress,D),percentage:A(J,D,"percentage"),total:A(E.total,D,"total"),value:A(E.value,D,"value"),eta:A(E.eta,D,"eta"),eta_formatted:B(E.eta,D,5),duration:A(X,D,"duration"),duration_formatted:B(X,D,1)});C=C.replace(/\{(\w+)\}/g,function(_,U){if(typeof Y[U]<"u")return Y[U];return _});let Z=Math.max(0,E.maxWidth-rF(C)-2),K=Math.floor(Z/2);switch(D.align){case"right":C=Z>0?" ".repeat(Z)+C:C;break;case"center":C=K>0?" ".repeat(K)+C:C;break;case"left":default:break}return C}});var JD=x((w3,vu)=>{function H(u,D){if(typeof u>"u"||u===null)return D;else return u}vu.exports={parse:function(D,E){let F={},C=Object.assign({},E,D);return F.throttleTime=1000/H(C.fps,10),F.stream=H(C.stream,process.stderr),F.terminal=H(C.terminal,null),F.clearOnComplete=H(C.clearOnComplete,!1),F.stopOnComplete=H(C.stopOnComplete,!1),F.barsize=H(C.barsize,40),F.align=H(C.align,"left"),F.hideCursor=H(C.hideCursor,!1),F.linewrap=H(C.linewrap,!1),F.barGlue=H(C.barGlue,""),F.barCompleteChar=H(C.barCompleteChar,"="),F.barIncompleteChar=H(C.barIncompleteChar,"-"),F.format=H(C.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),F.formatTime=H(C.formatTime,null),F.formatValue=H(C.formatValue,null),F.formatBar=H(C.formatBar,null),F.etaBufferLength=H(C.etaBuffer,10),F.etaAsynchronousUpdate=H(C.etaAsynchronousUpdate,!1),F.progressCalculationRelative=H(C.progressCalculationRelative,!1),F.synchronousUpdate=H(C.synchronousUpdate,!0),F.noTTYOutput=H(C.noTTYOutput,!1),F.notTTYSchedule=H(C.notTTYSchedule,2000),F.emptyOnZero=H(C.emptyOnZero,!1),F.forceRedraw=H(C.forceRedraw,!1),F.autopadding=H(C.autopadding,!1),F.gracefulExit=H(C.gracefulExit,!1),F},assignDerivedOptions:function(D){return D.barCompleteString=D.barCompleteChar.repeat(D.barsize+1),D.barIncompleteString=D.barIncompleteChar.repeat(D.barsize+1),D.autopaddingChar=D.autopadding?H(D.autopaddingChar," "):"",D}}});var bD=x((S3,hu)=>{var Pu=Nu(),eF=MD(),D8=TD(),u8=JD(),F8=p("events");hu.exports=class extends F8{constructor(D){super();this.options=u8.assignDerivedOptions(D),this.terminal=this.options.terminal?this.options.terminal:new eF(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 Pu(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format==="function"?this.options.format:D8}render(D=!1){let E={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 F=this.formatter(this.options,E,this.payload);if(D||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=F)this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(F),this.terminal.clearRight(),this.lastDrawnString=F,this.lastRedraw=Date.now(),this.emit("redraw-post")}start(D,E,F){this.value=E||0,this.total=typeof D<"u"&&D>=0?D:100,this.startValue=E||0,this.payload=F||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new Pu(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",D,E)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(D,E={}){if(typeof D==="number")this.value=D,this.eta.update(Date.now(),D,this.total);let F=(typeof D==="object"?D:E)||{};this.emit("update",this.total,this.value);for(let C in F)this.payload[C]=F[C];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,E={}){if(typeof D==="object")this.update(this.value+1,D);else this.update(this.value+D,E)}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 gu=x((T3,fu)=>{var E8=bD(),C8=JD();fu.exports=class extends E8{constructor(D,E){super(C8.parse(D,E));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,E){if(!this.timer)return;if(super.update(D,E),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2<Date.now())this.render()}start(D,E,F){if(this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return;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.terminal.cursorSave(),this.options.hideCursor===!0)this.terminal.cursor(!1);if(this.options.linewrap===!1)this.terminal.lineWrapping(!1);super.start(D,E,F),this.render()}stop(){if(!this.timer)return;if(this.sigintCallback)process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null;if(this.render(),super.stop(),clearTimeout(this.timer),this.timer=null,this.options.hideCursor===!0)this.terminal.cursor(!0);if(this.options.linewrap===!1)this.terminal.lineWrapping(!0);if(this.terminal.cursorRestore(),this.options.clearOnComplete)this.terminal.cursorTo(0,null),this.terminal.clearLine();else this.terminal.newline()}}});var cu=x((b3,mu)=>{var B8=MD(),A8=bD(),Z8=JD(),$8=p("events");mu.exports=class extends $8{constructor(D,E){super();this.bars=[],this.options=Z8.parse(D,E),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new B8(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,E,F,C={}){let B=new A8(Object.assign({},this.options,{terminal:this.terminal},C));if(this.bars.push(B),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return B;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,B.start(D,E,F),this.emit("start"),B}remove(D){let E=this.bars.indexOf(D);if(E<0)return!1;return this.bars.splice(E,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;D<this.bars.length;D++){if(D>0)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;D<this.bars.length;D++){if(D>0)this.terminal.newline();this.bars[D].render(),this.bars[D].stop()}this.terminal.newline()}this.emit("stop")}log(D){this.loggingBuffer.push(D)}}});var du=x((y3,lu)=>{lu.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var nu=x((v3,pu)=>{pu.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var au=x((P3,su)=>{su.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var iu=x((h3,ru)=>{ru.exports={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "}});var tu=x((f3,ou)=>{var J8=du(),K8=nu(),X8=au(),Y8=iu();ou.exports={legacy:J8,shades_classic:K8,shades_grey:X8,rect:Y8}});var uF=x((g3,DF)=>{var eu=gu(),G8=cu(),U8=tu(),k8=TD(),W8=jD(),_8=wD(),Q8=SD();DF.exports={Bar:eu,SingleBar:eu,MultiBar:G8,Presets:U8,Format:{Formatter:k8,BarFormat:_8,ValueFormat:W8,TimeFormat:Q8}}});import{join as $D,basename as Uu,extname as ku}from"node:path";import{randomUUID as cF}from"node:crypto";import{rm as Wu}from"node:fs/promises";import{spawn as DD}from"node:child_process";import{appendFile as xF}from"node:fs/promises";var QD=null;function ND(u){QD=u}async function h(u){if(QD)try{await xF(QD,u,"utf-8")}catch(D){}}async function n(){return new Promise((u)=>{let D=DD("ffmpeg",["-version"]);D.on("error",()=>u(!1)),D.on("close",(E)=>u(E===0))})}async function s(){return new Promise((u)=>{let D=DD("MP4Box",["-version"]);D.on("error",()=>u(!1)),D.on("close",(E)=>u(E===0))})}async function a(){let u=await new Promise((C)=>{let B=DD("ffmpeg",["-hide_banner","-encoders"]),A="";B.stdout.on("data",($)=>{A+=$.toString()}),B.on("error",()=>C("")),B.on("close",()=>C(A))}),D=(C)=>u.includes(C),E=[],F=[{acc:"nvenc",h264:D("h264_nvenc")?"h264_nvenc":void 0,av1:D("av1_nvenc")?"av1_nvenc":void 0},{acc:"qsv",h264:D("h264_qsv")?"h264_qsv":void 0,av1:D("av1_qsv")?"av1_qsv":void 0},{acc:"amf",h264:D("h264_amf")?"h264_amf":void 0,av1:D("av1_amf")?"av1_amf":void 0},{acc:"vaapi",h264:D("h264_vaapi")?"h264_vaapi":void 0,av1:D("av1_vaapi")?"av1_vaapi":void 0},{acc:"videotoolbox",h264:D("h264_videotoolbox")?"h264_videotoolbox":void 0,av1:D("av1_videotoolbox")?"av1_videotoolbox":void 0},{acc:"v4l2",h264:D("h264_v4l2m2m")?"h264_v4l2m2m":void 0,av1:D("av1_v4l2m2m")?"av1_v4l2m2m":void 0}];for(let C of F)if(C.h264||C.av1)E.push({accelerator:C.acc,h264Encoder:C.h264,av1Encoder:C.av1});return E}async function c(u,D,E){let C=`
=== FFmpeg Command [${new Date().toISOString()}] ===
ffmpeg ${u.join(" ")}
`;return await h(C),new Promise((B,A)=>{let $=DD("ffmpeg",u),J="";$.stderr.on("data",(G)=>{let X=G.toString();if(J+=X,D&&E){let Y=X.match(/time=(\d{2}):(\d{2}):(\d{2}\.\d{2})/);if(Y){let Z=parseInt(Y[1]),K=parseInt(Y[2]),_=parseFloat(Y[3]),U=Z*3600+K*60+_,q=Math.min(100,U/E*100);D(q)}}}),$.on("error",(G)=>{h(`ERROR: ${G.message}
`),A(Error(`FFmpeg error: ${G.message}`))}),$.on("close",(G)=>{if(G===0){let Y=J.split(`
`).filter((Z)=>Z.trim()).slice(-10).join(`
`);h(`SUCCESS: Exit code ${G}
--- Last 10 lines of output ---
${Y}
`),B()}else h(`FAILED: Exit code ${G}
--- Full error output ---
${J}
`),A(Error(`FFmpeg failed with exit code ${G}
${J}`))})})}async function zD(u){let E=`
=== MP4Box Command [${new Date().toISOString()}] ===
MP4Box ${u.join(" ")}
`;return await h(E),new Promise((F,C)=>{let B=DD("MP4Box",u),A="",$="";B.stdout.on("data",(J)=>{A+=J.toString()}),B.stderr.on("data",(J)=>{$+=J.toString()}),B.on("error",(J)=>{h(`ERROR: ${J.message}
`),C(Error(`MP4Box error: ${J.message}`))}),B.on("close",(J)=>{if(J===0){let Y=(A||$).split(`
`).filter((Z)=>Z.trim()).slice(-10).join(`
`);h(`SUCCESS: Exit code ${J}
--- Last 10 lines of output ---
${Y}
`),F()}else{let G=$||A;h(`FAILED: Exit code ${J}
--- Full error output ---
${G}
`),C(Error(`MP4Box failed with exit code ${J}
${G}`))}})})}import{spawn as VF}from"node:child_process";async function r(u){return new Promise((D,E)=>{let F=VF("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]),C="";F.stdout.on("data",(B)=>{C+=B.toString()}),F.on("error",(B)=>{E(Error(`ffprobe error: ${B.message}`))}),F.on("close",(B)=>{if(B!==0){E(Error(`ffprobe failed with exit code ${B}`));return}try{let A=JSON.parse(C),$=A.streams.find((U)=>U.codec_type==="video"),J=A.streams.find((U)=>U.codec_type==="audio"),G=A.format;if(!$){E(Error("No video stream found in input file"));return}let X=30;if($.r_frame_rate){let[U,q]=$.r_frame_rate.split("/").map(Number);if(U&&q&&q!==0)X=U/q}let Y=parseFloat($.duration||G.duration||"0"),Z=A.streams.find((U)=>U.codec_type==="audio"&&U.bit_rate),K=Z?.bit_rate?Math.round(parseInt(Z.bit_rate)/1000):void 0,_=$.bit_rate?Math.round(parseInt($.bit_rate)/1000):void 0;D({width:$.width,height:$.height,duration:Y,fps:X,codec:$.codec_name,hasAudio:Boolean(J),audioBitrate:K,videoBitrate:_})}catch(A){E(Error(`Failed to parse ffprobe output: ${A}`))}})})}function CD(u,D=256){if(!u)return`${D}k`;let E=Math.min(u,D);if(E<=64)return"64k";if(E<=96)return"96k";if(E<=128)return"128k";if(E<=192)return"192k";return"256k"}function BD(u){let D=Math.floor(u/3600),E=Math.floor(u%3600/60),F=u%60;return`${String(D).padStart(2,"0")}:${String(E).padStart(2,"0")}:${F.toFixed(3).padStart(6,"0")}`}import{mkdir as LF,access as MF,constants as OF}from"node:fs/promises";async function l(u){try{await MF(u,OF.F_OK)}catch{await LF(u,{recursive:!0})}}function wF(u,D){let E=u*D;if(E<=230400)return 0.08;if(E<=409920)return 0.075;if(E<=921600)return 0.07;if(E<=2073600)return 0.065;if(E<=3686400)return 0.06;return 0.055}function v(u,D,E=30,F){let C=wF(u,D),B=Math.round(u*D*E*C/1000);if(F&&B>F)B=F;return`${B}k`}var HD=[{name:"360p",width:640,height:360,videoBitrate:v(640,360,30),audioBitrate:"192k"},{name:"480p",width:854,height:480,videoBitrate:v(854,480,30),audioBitrate:"192k"},{name:"720p",width:1280,height:720,videoBitrate:v(1280,720,30),audioBitrate:"192k"},{name:"1080p",width:1920,height:1080,videoBitrate:v(1920,1080,30),audioBitrate:"256k"},{name:"1440p",width:2560,height:1440,videoBitrate:v(2560,1440,30),audioBitrate:"256k"},{name:"2160p",width:3840,height:2160,videoBitrate:v(3840,2160,30),audioBitrate:"256k"}];function uD(u,D,E=30,F){let C=[],B=HD.filter((A)=>{return A.width<=u&&A.height<=D});for(let A of B)C.push({...A,videoBitrate:v(A.width,A.height,30,F),fps:30});return C}function SF(u,D,E){return{...u,name:`${u.name}-${D}`,videoBitrate:v(u.width,u.height,D,E),fps:D}}function eD(u){let E=u.trim().match(/^(\d+)p?(?:[@-](\d+))?$/i);if(!E)return null;let F=E[1]+"p",C=E[2]?parseInt(E[2]):30;return{resolution:F,fps:C}}function Du(u,D=30,E){let F=HD.find((C)=>C.name===u);if(!F)return null;if(D===30)return{...F,videoBitrate:v(F.width,F.height,30,E),fps:30};return SF(F,D,E)}function TF(u,D,E,F){let C=eD(u);if(!C)return{error:`Invalid profile format: ${u}. Use format like: 360, 720@60, 1080-60`};let B=Du(C.resolution,C.fps);if(!B)return{error:`Unknown resolution: ${C.resolution}. Available: 360, 480, 720, 1080, 1440, 2160`};if(B.width>D||B.height>E)return{error:`Source resolution (${D}x${E}) is lower than ${u} (${B.width}x${B.height})`};let A=120,$=C.fps,J;if(C.fps>F)$=Math.min(F,A),J=`Requested ${C.fps} FPS in ${u}, but source is ${F} FPS. Using ${$} FPS instead`;else if(C.fps>A)$=A,J=`Requested ${C.fps} FPS in ${u} exceeds maximum ${A} FPS. Using ${$} FPS instead`;return J?{warning:J,adjustedFps:$}:{}}function AD(u,D,E,F,C){let B=[],A=[],$=[];for(let J of u){let G=TF(J,D,E,F);if(G.error){A.push(G.error);continue}if(G.warning)$.push(G.warning);let X=eD(J);if(!X)continue;let Y=G.adjustedFps!==void 0?G.adjustedFps:X.fps,Z=Du(X.resolution,Y,C);if(Z)B.push(Z)}return{profiles:B,errors:A,warnings:$}}import{join as f}from"node:path";import{readdir as bF,unlink as uu,rmdir as yF,writeFile as Fu}from"node:fs/promises";async function Eu(u,D,E="00:00:00"){let F=f(D,"poster.jpg"),C=/^\d+(\.\d+)?$/.test(E)?E:E;return await c(["-ss",C,"-i",u,"-vframes","1","-q:v","2","-y",F]),F}async function Cu(u,D,E,F){let{width:C,height:B,interval:A,columns:$}=F,J=f(D,".thumbnails_temp");await l(J),await Fu(f(J,".keep"),"");let G=f(J,"thumb_%04d.jpg");await c(["-i",u,"-vf",`fps=1/${A},scale=${C}:${B}`,"-q:v","5",G]);let Y=(await bF(J)).filter((W)=>W.startsWith("thumb_")&&W.endsWith(".jpg")).sort();if(Y.length===0)throw Error("No thumbnails generated");let Z=Y.length,K=Math.ceil(Z/$),_=f(D,"thumbnails.jpg"),U=`tile=${$}x${K}`;await c(["-i",G,"-filter_complex",U,"-q:v","5",_]);let q=f(D,"thumbnails.vtt"),k=vF(Z,A,C,B,$,"thumbnails.jpg");await Fu(q,k);for(let W of Y)await uu(f(J,W));return await uu(f(J,".keep")),await yF(J),{spritePath:_,vttPath:q}}function vF(u,D,E,F,C,B){let A=`WEBVTT
`;for(let $=0;$<u;$++){let J=$*D,G=($+1)*D,X=Math.floor($/C),Z=$%C*E,K=X*F;A+=`${BD(J)} --> ${BD(G)}
`,A+=`${B}#xywh=${Z},${K},${E},${F}
`}return A}import{join as PF}from"node:path";function hF(u,D,E){if(E)if(D==="h264")return 32;else return 42;else if(D==="h264"){if(u<=360)return 25;if(u<=480)return 24;if(u<=720)return 23;if(u<=1080)return 22;if(u<=1440)return 21;return 20}else{if(u<=360)return 40;if(u<=480)return 38;if(u<=720)return 35;if(u<=1080)return 32;if(u<=1440)return 30;return 28}}async function Bu(u,D,E,F,C,B,A,$,J,G,X,Y){let Z=PF(D,`video_${J}_${E.name}.mp4`),K=["-y","-i",u,"-c:v",F],_=F.includes("nvenc")||F.includes("qsv")||F.includes("amf")||F.includes("vaapi")||F.includes("videotoolbox")||F.includes("v4l2"),U;if(_&&G?.cq!==void 0)U=G.cq;else if(!_&&G?.crf!==void 0)U=G.crf;else U=hF(E.height,J,_);if(F==="h264_nvenc")K.push("-rc:v","vbr"),K.push("-cq",String(U)),K.push("-preset",C),K.push("-2pass","0");else if(F==="av1_nvenc")K.push("-rc:v","vbr"),K.push("-cq",String(U)),K.push("-preset",C),K.push("-2pass","0");else if(F==="av1_qsv")K.push("-preset",C),K.push("-global_quality",String(U));else if(F==="h264_qsv")K.push("-preset",C),K.push("-global_quality",String(U));else if(F==="av1_amf")K.push("-quality","balanced"),K.push("-rc","cqp"),K.push("-qp_i",String(U)),K.push("-qp_p",String(U));else if(F==="h264_amf")K.push("-quality","balanced"),K.push("-rc","cqp"),K.push("-qp_i",String(U)),K.push("-qp_p",String(U));else if(F==="libsvtav1")K.push("-crf",String(U)),K.push("-preset",C),K.push("-svtav1-params","tune=0:enable-overlays=1");else if(F==="libx264")K.push("-crf",String(U)),K.push("-preset",C);else K.push("-preset",C);let q=J==="av1"?0.6:1,k=Math.round(parseInt(E.videoBitrate)*q*1.5);K.push("-maxrate",`${k}k`),K.push("-bufsize",`${k*2}k`);let W=E.fps||30,z=Math.round(W*A);K.push("-g",String(z),"-keyint_min",String(z),"-sc_threshold","0");let V=[`scale=${E.width}:${E.height}`];if(X){if(X.deinterlace)V.push("yadif");if(X.denoise)V.push("hqdn3d");if(X.customFilters)V.push(...X.customFilters)}K.push("-vf",V.join(","));let j=parseInt(E.audioBitrate)||256,w=CD($,j);if(K.push("-c:a","aac","-b:a",w),X?.audioNormalize)K.push("-af","loudnorm");return K.push("-f","mp4",Z),await c(K,Y,B),Z}async function Au(u,D,E,F,C,B,A,$,J,G,X,Y,Z,K){let _=new Map;if(J&&E.length>1)for(let U=0;U<E.length;U+=G){let q=E.slice(U,U+G),k=q.map((z)=>Bu(u,D,z,F,C,B,A,$,X,Y,Z,(V)=>{if(K)K(z.name,V)}));(await Promise.all(k)).forEach((z,V)=>{let j=q[V];_.set(j.name,z)})}else for(let U of E){let q=await Bu(u,D,U,F,C,B,A,$,X,Y,Z,(k)=>{if(K)K(U.name,k)});_.set(U.name,q)}return _}import{join as M}from"node:path";import{readdir as Xu,rename as E3,mkdir as C3,writeFile as VD}from"node:fs/promises";import{readFile as qD,writeFile as ID}from"node:fs/promises";async function Zu(u){let D=await qD(u,"utf-8");D=D.replace(/\/\/>/g,"/>"),D=D.replace(/\/\s+\/>/g,"/>"),D=D.replace(/(<Representation[^>]+)\s+\/>/g,"$1/>"),D=D.replace(/<Representation\s+([^>]+)\/>\s*<\/Representation>/g,"<Representation $1/>"),D=D.replace(/<Representation\s+([^>]+)\/>\s*(<AudioChannelConfiguration[^>]*\/>)/g,`<Representation $1>
$2
</Representation>`),D=D.replace(/<Representation\s+([^>]+)>\s*(?=<(?:Representation|\/AdaptationSet))/g,`<Representation $1/>
`),await ID(u,D,"utf-8")}async function $u(u,D,E){let F=await qD(u,"utf-8");F=F.replace(/media="\$RepresentationID\$_\$Number\$\.m4s"/g,'media="$RepresentationID$/$RepresentationID$_$Number$.m4s"'),F=F.replace(/initialization="\$RepresentationID\$_\.mp4"/g,'initialization="$RepresentationID$/$RepresentationID$_.mp4"'),await ID(u,F,"utf-8")}async function Ju(u){let E=(await qD(u,"utf-8")).split(`
`),F=[],C=0;while(C<E.length){let B=E[C];if(B.includes("<AdaptationSet")&&B.includes("maxWidth")){let A=C,$=[B],J=[],G=[],X=[],Y=!1;C++;while(C<E.length&&!E[C].includes("</AdaptationSet>")){let Z=E[C];if(Z.includes("<SegmentTemplate"))Y=!0;if(Y){if(J.push(Z),Z.includes("</SegmentTemplate>"))Y=!1}else if(Z.includes("<Representation")&&Z.includes("-h264"))G.push(Z);else if(Z.includes("<Representation")&&Z.includes("-av1"))X.push(Z);C++}if(G.length>0&&X.length>0)F.push(B),J.forEach((Z)=>F.push(Z)),G.forEach((Z)=>F.push(Z)),F.push(" </AdaptationSet>"),F.push(B),J.forEach((Z)=>F.push(Z)),X.forEach((Z)=>F.push(Z)),F.push(" </AdaptationSet>");else{F.push(B);for(let Z=A+1;Z<C;Z++)F.push(E[Z]);F.push(E[C])}C++}else F.push(B),C++}await ID(u,F.join(`
`),"utf-8")}function xD(u,D,E){let F=`#EXTM3U
`;F+=`#EXT-X-VERSION:6
`,F+=`#EXT-X-TARGETDURATION:${Math.ceil(E)}
`,F+=`#EXT-X-MEDIA-SEQUENCE:1
`,F+=`#EXT-X-INDEPENDENT-SEGMENTS
`,F+=`#EXT-X-MAP:URI="${D}"
`;for(let C of u)F+=`#EXTINF:${E},
`,F+=`${C}
`;return F+=`#EXT-X-ENDLIST
`,F}function Ku(u,D){let E=`#EXTM3U
`;if(E+=`#EXT-X-VERSION:6
`,E+=`#EXT-X-INDEPENDENT-SEGMENTS
`,D)E+=`#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio",AUTOSELECT=YES,URI="audio/playlist.m3u8",CHANNELS="2"
`;for(let F of u){let C=D?"avc1.4D4020,mp4a.40.2":"avc1.4D4020";if(E+=`#EXT-X-STREAM-INF:BANDWIDTH=${F.bandwidth},CODECS="${C}",RESOLUTION=${F.resolution},FRAME-RATE=${F.fps}`,D)E+=',AUDIO="audio"';E+=`
`,E+=`${F.path}
`}return E}async function fF(u,D,E,F,C,B){let A=M(D,"manifest.mpd"),$=["-dash",String(F*1000),"-frag",String(F*1000),"-rap","-segment-timeline","-segment-name","$RepresentationID$_$Number$","-out",A],J=!0;for(let[G,X]of u.entries())for(let Y of E){let Z=X.get(Y.name);if(!Z)throw Error(`MP4 file not found for profile: ${Y.name}, codec: ${G}`);let K=C==="dual"?`${Y.name}-${G}`:Y.name;if($.push(`${Z}#video:id=${K}`),J&&B)$.push(`${Z}#audio:id=audio`),J=!1}if(await zD($),await gF(D,E,C,B),await $u(A,E,C),C==="dual")await Ju(A);return await Zu(A),A}async function gF(u,D,E,F){let{readdir:C,rename:B,mkdir:A}=await import("node:fs/promises"),$=[];if(E==="h264"||E==="dual")$.push("h264");if(E==="av1"||E==="dual")$.push("av1");let J=[];for(let Y of $)for(let Z of D){let K=E==="dual"?`${Z.name}-${Y}`:Z.name;J.push(K);let _=M(u,K);await A(_,{recursive:!0})}let G=M(u,"audio");if(F)await A(G,{recursive:!0});let X=await C(u);for(let Y of X){if(Y==="manifest.mpd")continue;if(F&&(Y.startsWith("audio_")||Y==="audio_init.m4s")){let Z=M(u,Y),K=M(G,Y);await B(Z,K);continue}for(let Z of J)if(Y.startsWith(`${Z}_`)){let K=M(u,Y),_=M(u,Z,Y);await B(K,_);break}}}async function Yu(u,D,E,F,C,B,A){let $,J;if(B==="dash"||B==="both")$=await fF(u,D,E,F,C,A);if(B==="hls"||B==="both")J=await mF(D,E,F,C,A);return{manifestPath:$,hlsManifestPath:J}}async function mF(u,D,E,F,C){let B=M(u,"master.m3u8"),A=[];for(let X of D){let Y=F==="dual"?`${X.name}-h264`:X.name,Z=M(u,Y),K=await Xu(Z),_=K.filter((z)=>z.endsWith(".m4s")).sort((z,V)=>{let j=parseInt(z.match(/_(\d+)\.m4s$/)?.[1]||"0"),w=parseInt(V.match(/_(\d+)\.m4s$/)?.[1]||"0");return j-w}),U=K.find((z)=>z.endsWith("_.mp4"));if(!U||_.length===0)continue;let q=xD(_,U,E),k=M(Z,"playlist.m3u8");await VD(k,q,"utf-8");let W=parseInt(X.videoBitrate)*1000;A.push({path:`${Y}/playlist.m3u8`,bandwidth:W,resolution:`${X.width}x${X.height}`,fps:X.fps||30})}let $,J=[];if(C){let X=M(u,"audio"),Y=[];try{Y=await Xu(X)}catch{Y=[]}if(J=Y.filter((Z)=>Z.endsWith(".m4s")).sort((Z,K)=>{let _=parseInt(Z.match(/_(\d+)\.m4s$/)?.[1]||"0"),U=parseInt(K.match(/_(\d+)\.m4s$/)?.[1]||"0");return _-U}),$=Y.find((Z)=>Z.endsWith("_.mp4")),$&&J.length>0){let Z=xD(J,$,E);await VD(M(X,"playlist.m3u8"),Z,"utf-8")}}let G=Ku(A,C&&$!==void 0&&J.length>0);return await VD(B,G,"utf-8"),B}async function LD(u){let{input:D,outputDir:E,segmentDuration:F=2,profiles:C,customProfiles:B,codec:A="dual",format:$="both",useNvenc:J,hardwareAccelerator:G,quality:X,generateThumbnails:Y=!0,thumbnailConfig:Z={},generatePoster:K=!0,posterTimecode:_="00:00:00",parallel:U=!0,onProgress:q}=u,k=$D("/tmp",`dash-converter-${cF()}`);await l(k);let W=Uu(D,ku(D)),z=$D(E,W);await l(z);let V=$D(z,"conversion.log");ND(V);let{writeFile:j}=await import("node:fs/promises"),w=`===========================================
DASH Conversion Log
Started: ${new Date().toISOString()}
Input: ${D}
Output: ${z}
Codec: ${A}
Format: ${$}
===========================================
`;await j(V,w,"utf-8");try{return await lF(D,E,k,F,C,B,A,$,J,G,X,Y,Z,K,_,U,q)}finally{let{appendFile:GD}=await import("node:fs/promises");try{await GD(V,`
Completed: ${new Date().toISOString()}
`,"utf-8")}catch(UD){}try{await Wu(k,{recursive:!0,force:!0})}catch(UD){console.warn(`Warning: Failed to cleanup temp directory: ${k}`)}}}async function lF(u,D,E,F,C,B,A,$,J,G,X,Y,Z,K,_,U,q){if(!await n())throw Error("FFmpeg is not installed or not in PATH");if(!await s())throw Error("MP4Box is not installed or not in PATH. Install gpac package.");let k=(N,I,WD,_D)=>{if(q)q({stage:N,percent:I,message:WD,currentProfile:_D})};k("analyzing",0,"Analyzing input video...");let W=await r(u),z=W.hasAudio,V=G&&G!=="auto"?G:J===!0?"nvenc":J===!1?"cpu":"auto",j=await a(),{selected:w,h264Encoder:GD,av1Encoder:UD,warnings:lD}=dF(j,V,A);if(lD.length>0)for(let N of lD)console.warn(`⚠️ ${N}`);let $F=j.some((N)=>N.av1Encoder),m=A;if(A==="dual"&&!$F)console.warn("⚠️ AV1 hardware encoder not detected. Switching to H.264 only."),m="h264";let O;if(B&&B.length>0){let N=AD(B,W.width,W.height,W.fps,W.videoBitrate);if(N.errors.length>0){console.warn(`
❌ Profile errors:`);for(let I of N.errors)console.warn(` - ${I}`);console.warn("")}if(N.warnings.length>0){console.warn(`
⚠️ Profile warnings:`);for(let I of N.warnings)console.warn(` - ${I}`);console.warn("")}if(O=N.profiles,O.length===0)throw Error("No valid profiles found in custom list. Check errors above.")}else if(C)O=C;else O=uD(W.width,W.height,W.fps,W.videoBitrate);if(O.length===0)throw Error("No suitable profiles found for input video resolution");let JF=Uu(u,ku(u)),t=$D(D,JF);try{await Wu(t,{recursive:!0,force:!0})}catch(N){}await l(t);let P=[];if(m==="h264"||m==="dual"){let N=GD||"libx264",I=Gu(N,"h264");P.push({type:"h264",codec:N,preset:I})}if(m==="av1"||m==="dual"){let N=UD||"libsvtav1",I=Gu(N,"av1");P.push({type:"av1",codec:N,preset:I})}let KF=P.map((N)=>N.type.toUpperCase()).join(" + "),XF=w==="cpu"?"CPU":w.toUpperCase();k("analyzing",20,`Using ${KF} encoding (${XF})`,void 0);let YF=w==="cpu"?2:3,kD=new Map;for(let N=0;N<P.length;N++){let{type:I,codec:WD,preset:_D}=P[N],aD=N/P.length,kF=1/P.length;k("encoding",25+aD*40,`Stage 1: Encoding ${I.toUpperCase()} (${O.length} profiles)...`);let WF=I==="h264"?X?.h264:X?.av1,_F=await Au(u,E,O,WD,_D,W.duration,F,W.audioBitrate,U,YF,I,WF,void 0,(e,rD)=>{let R8=O.findIndex((QF)=>QF.name===e),iD=25+aD*40,oD=rD/100*(40*kF/O.length);if(k("encoding",iD+oD,`Encoding ${I.toUpperCase()} ${e}...`,`${I}-${e}`),q)q({stage:"encoding",percent:iD+oD,currentProfile:`${I}-${e}`,profilePercent:rD,message:`Encoding ${I.toUpperCase()} ${e}...`})});kD.set(I,_F)}k("encoding",65,"Stage 1 complete: All codecs and profiles encoded"),k("encoding",70,"Stage 2: Creating segments and manifests...");let{manifestPath:GF,hlsManifestPath:UF}=await Yu(kD,t,O,F,m,$,z),dD=[];for(let N of kD.values())dD.push(...Array.from(N.values()));k("encoding",80,"Stage 2 complete: All formats packaged");let pD,nD;if(Y){k("thumbnails",80,"Generating thumbnail sprites...");let N={width:Z.width||160,height:Z.height||90,interval:Z.interval||1,columns:Z.columns||10},I=await Cu(u,t,W.duration,N);pD=I.spritePath,nD=I.vttPath,k("thumbnails",90,"Thumbnails generated")}let sD;if(K)k("thumbnails",92,"Generating poster image..."),sD=await Eu(u,t,_),k("thumbnails",95,"Poster generated");return k("manifest",95,"Finalizing..."),k("complete",100,"Conversion complete!"),{manifestPath:GF,hlsManifestPath:UF,videoPaths:dD,thumbnailSpritePath:pD,thumbnailVttPath:nD,posterPath:sD,duration:W.duration,profiles:O,usedNvenc:P.some((N)=>N.codec.includes("nvenc")),selectedAccelerator:w,codecType:m,format:$}}var ZD={nvenc:100,qsv:90,amf:80,vaapi:70,videotoolbox:65,v4l2:60,cpu:1};function dF(u,D,E){let F=E==="h264"||E==="dual",C=E==="av1"||E==="dual",B=[],A=new Set(["nvenc","qsv","amf"]),$=u.filter((k)=>F&&k.h264Encoder||C&&k.av1Encoder),J=$.filter((k)=>A.has(k.accelerator)),G=(k)=>$.find((W)=>W.accelerator===k),X;if(D!=="auto"){if(D==="cpu")X=void 0;else if(!A.has(D))B.push(`Ускоритель "${D}" пока не поддерживается, использую CPU`);else if(X=G(D),!X)throw Error(`Аппаратный ускоритель "${D}" недоступен в системе`)}else if(X=(J.length>0?J:[]).sort((W,z)=>(ZD[z.accelerator]||0)-(ZD[W.accelerator]||0))[0],!X&&$.length>0)B.push("Доступен аппаратный ускоритель, но он пока не поддерживается пайплайном, использую CPU");let Z=(J.length>0?J:[]).sort((k,W)=>(ZD[W.accelerator]||0)-(ZD[k.accelerator]||0)),K=(k)=>{let W=k==="h264"?X?.h264Encoder:X?.av1Encoder;if(W)return{encoder:W,accel:X?.accelerator};let z=Z.find((V)=>k==="h264"?V.h264Encoder:V.av1Encoder);if(z){if(D!=="auto"&&X)B.push(`Выбранный ускоритель "${X.accelerator}" не поддерживает ${k.toUpperCase()}, использую ${z.accelerator}`);return{encoder:k==="h264"?z.h264Encoder:z.av1Encoder,accel:z.accelerator}}if(D!=="auto"&&D!=="cpu")B.push(`Ускоритель "${D}" не поддерживает ${k.toUpperCase()}, использую CPU`);return{encoder:void 0,accel:"cpu"}},_=F?K("h264"):{encoder:void 0,accel:X?.accelerator},U=C?K("av1"):{encoder:void 0,accel:X?.accelerator};return{selected:X?.accelerator||_.accel||U.accel||"cpu",h264Encoder:_.encoder,av1Encoder:U.encoder,warnings:B}}function Gu(u,D){if(u.includes("nvenc"))return"p4";if(u.includes("qsv"))return"medium";if(u.includes("amf"))return"balanced";if(u.includes("vaapi"))return"5";if(u.includes("videotoolbox"))return"medium";if(u.includes("v4l2"))return"medium";if(u==="libsvtav1")return"8";if(u==="libx264")return"medium";return D==="av1"?"8":"medium"}var PD=ED(uF(),1);import{statSync as N8}from"node:fs";var Q=process.argv.slice(2),FD,gD,R="dual",i="both",mD=[],S,T,b,y,EF;for(let u=0;u<Q.length;u++)if(Q[u]==="-r"||Q[u]==="--resolutions"){let D=[];for(let F=u+1;F<Q.length;F++){if(Q[F].startsWith("-"))break;D.push(Q[F]),u=F}FD=D.join(",").split(/[,\s]+/).map((F)=>F.trim()).filter((F)=>F.length>0)}else if(Q[u]==="-p"||Q[u]==="--poster")gD=Q[u+1],u++;else if(Q[u]==="-c"||Q[u]==="--codec"){let D=Q[u+1];if(D==="av1"||D==="h264"||D==="dual")R=D;else console.error(`❌ Invalid codec: ${D}. Valid options: av1, h264, dual`),process.exit(1);u++}else if(Q[u]==="-f"||Q[u]==="--format"){let D=Q[u+1];if(D==="dash"||D==="hls"||D==="both")i=D;else console.error(`❌ Invalid format: ${D}. Valid options: dash, hls, both`),process.exit(1);u++}else if(Q[u]==="--h264-cq"){if(S=parseInt(Q[u+1]),isNaN(S)||S<0||S>51)console.error(`❌ Invalid H.264 CQ value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--h264-crf"){if(T=parseInt(Q[u+1]),isNaN(T)||T<0||T>51)console.error(`❌ Invalid H.264 CRF value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--av1-cq"){if(b=parseInt(Q[u+1]),isNaN(b)||b<0||b>51)console.error(`❌ Invalid AV1 CQ value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--av1-crf"){if(y=parseInt(Q[u+1]),isNaN(y)||y<0||y>63)console.error(`❌ Invalid AV1 CRF value: ${Q[u+1]}. Must be 0-63`),process.exit(1);u++}else if(Q[u]==="--accel"||Q[u]==="--hardware"){let D=Q[u+1];if(!["auto","nvenc","qsv","amf","cpu"].includes(D))console.error(`❌ Invalid accelerator: ${D}. Valid: auto, nvenc, qsv, amf, cpu`),process.exit(1);EF=D,u++}else if(!Q[u].startsWith("-"))mD.push(Q[u]);var o=mD[0],CF=mD[1]||".";if(!o)console.error("❌ Usage: create-vod <input-video> [output-dir] [options]"),console.error(`
Options:`),console.error(" -r, --resolutions Video resolutions (e.g., 360,480,720 or 720@60,1080@60)"),console.error(" -c, --codec Video codec: av1, h264, or dual (default: dual)"),console.error(" -f, --format Streaming format: dash, hls, or both (default: both)"),console.error(" -p, --poster Poster timecode (e.g., 00:00:05 or 10)"),console.error(" --accel <type> Hardware accelerator: auto|nvenc|qsv|amf|cpu (default: auto)"),console.error(`
Quality Options (override defaults):`),console.error(" --h264-cq <value> H.264 GPU CQ value (0-51, lower = better, default: auto)"),console.error(" --h264-crf <value> H.264 CPU CRF value (0-51, lower = better, default: auto)"),console.error(" --av1-cq <value> AV1 GPU CQ value (0-51, lower = better, default: auto)"),console.error(" --av1-crf <value> AV1 CPU CRF value (0-63, lower = better, default: auto)"),console.error(`
Examples:`),console.error(" create-vod video.mp4"),console.error(" create-vod video.mp4 ./output"),console.error(" create-vod video.mp4 -r 360,480,720"),console.error(" create-vod video.mp4 -c av1 --av1-cq 40"),console.error(" create-vod video.mp4 -c dual --h264-cq 30 --av1-cq 39"),console.error(" create-vod video.mp4 -f hls"),console.error(" create-vod video.mp4 -c dual -f both"),console.error(" create-vod video.mp4 -r 720@60,1080@60,2160@60 -c av1 -f dash"),console.error(" create-vod video.mp4 -p 00:00:05"),console.error(" create-vod video.mp4 ./output -r 720,1080 -c dual -f both -p 10 --h264-cq 28 --av1-cq 37"),process.exit(1);console.log(`\uD83D\uDD0D Checking system...
`);var BF=await n(),AF=await s(),cD=await a(),ZF=cD.some((u)=>u.av1Encoder),FF={nvenc:100,qsv:90,amf:80,vaapi:70,videotoolbox:65,v4l2:60},XD=cD.slice().sort((u,D)=>(FF[D.accelerator]||0)-(FF[u.accelerator]||0))[0];console.log(`FFmpeg: ${BF?"✅":"❌"}`);console.log(`MP4Box: ${AF?"✅":"❌"}`);var z8=Array.from(new Set(cD.map((u)=>u.accelerator.toUpperCase()))),hD=XD?XD.accelerator.toUpperCase():void 0,YD=z8.filter((u)=>u!==hD),H8=hD?`${hD}${YD.length>0?` (${YD.join(", ")})`:""}`:"❌";console.log(`Hardware: ${H8}`);console.log("");if(!BF)console.error("❌ FFmpeg not found. Please install FFmpeg first."),process.exit(1);if(!AF)console.error("❌ MP4Box not found. Please install: sudo pacman -S gpac"),process.exit(1);if((R==="av1"||R==="dual")&&!ZF){if(R==="av1")console.error("⚠️ Warning: AV1 encoding requested but no hardware AV1 encoder found."),console.error(" CPU-based AV1 encoding (libsvtav1) will be VERY slow."),console.error(` Consider using --codec h264 for faster encoding.
`);else if(R==="dual")console.warn("⚠️ AV1 hardware encoder not detected. Using H.264 only (disable AV1)."),R="h264"}if((i==="hls"||i==="both")&&R==="av1")console.error("❌ Error: HLS format requires H.264 codec for Safari/iOS compatibility."),console.error(` Please use --codec h264 or --codec dual with --format hls
`),process.exit(1);console.log(`\uD83D\uDCCA Analyzing video...
`);var L=await r(o),q8=N8(o),I8=(q8.size/1048576).toFixed(2);console.log("\uD83D\uDCF9 Video Information:");console.log(` File: ${o}`);console.log(` Size: ${I8} MB`);console.log(` Resolution: ${L.width}x${L.height}`);console.log(` FPS: ${L.fps.toFixed(2)}`);console.log(` Duration: ${Math.floor(L.duration/60)}m ${Math.floor(L.duration%60)}s`);console.log(` Codec: ${L.codec}`);if(L.videoBitrate)console.log(` Video Bitrate: ${(L.videoBitrate/1000).toFixed(2)} Mbps`);if(L.audioBitrate)console.log(` Audio Bitrate: ${L.audioBitrate} kbps`);var fD=[];if(FD&&FD.length>0){let u=AD(FD,L.width,L.height,L.fps,L.videoBitrate);if(u.errors.length>0)console.error(`
❌ Profile errors:`),u.errors.forEach((D)=>console.error(` - ${D}`)),process.exit(1);if(u.warnings.length>0)console.warn(`
⚠️ Profile warnings:`),u.warnings.forEach((D)=>console.warn(` - ${D}`));fD=u.profiles.map((D)=>D.name)}else fD=uD(L.width,L.height,L.fps,L.videoBitrate).map((D)=>D.name);var x8=i==="both"?"DASH (manifest.mpd), HLS (master.m3u8)":i==="dash"?"DASH (manifest.mpd)":"HLS (master.m3u8)",V8=!0,L8=gD||"00:00:00",M8=R==="dual"?"dual (AV1 + H.264)":R,O8=R==="h264"&&YD&&YD.length>=0&&!ZF?" (AV1 disabled: no HW)":"";console.log(`
\uD83D\uDCE6 Parameters:`);console.log(` Input: ${o}`);console.log(` Output: ${CF}`);console.log(` Codec: ${M8}${O8}`);console.log(` Profiles: ${fD.join(", ")}`);console.log(` Manifests: ${x8}`);console.log(` Poster: ${L8} (will be generated)`);console.log(` Thumbnails: ${V8?"yes (with VTT)":"no"}`);console.log(` Accelerator: ${XD?XD.accelerator.toUpperCase():"CPU"}`);var g;if(S!==void 0||T!==void 0||b!==void 0||y!==void 0){if(g={},S!==void 0||T!==void 0){if(g.h264={},S!==void 0)g.h264.cq=S;if(T!==void 0)g.h264.crf=T;console.log(`\uD83C\uDF9A H.264 Quality: ${S!==void 0?`CQ ${S}`:""}${T!==void 0?` CRF ${T}`:""}`)}if(b!==void 0||y!==void 0){if(g.av1={},b!==void 0)g.av1.cq=b;if(y!==void 0)g.av1.crf=y;console.log(`\uD83C\uDF9A AV1 Quality: ${b!==void 0?`CQ ${b}`:""}${y!==void 0?` CRF ${y}`:""}`)}}console.log(`
\uD83D\uDE80 Starting conversion...
`);var KD=new PD.default.MultiBar({format:"{stage} | {bar} | {percentage}% | {name}",barCompleteChar:"█",barIncompleteChar:"░",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},PD.default.Presets.shades_classic),yD={},vD=null;try{let u=await LD({input:o,outputDir:CF,customProfiles:FD,posterTimecode:gD,codec:R,format:i,segmentDuration:2,hardwareAccelerator:EF,quality:g,generateThumbnails:!0,generatePoster:!0,parallel:!0,onProgress:(D)=>{let E=D.stage==="encoding"?"Encoding":D.stage==="thumbnails"?"Thumbnails":D.stage==="manifest"?"Manifest":D.stage==="analyzing"?"Analyzing":"Complete";if(D.stage==="encoding"&&D.currentProfile){if(!yD[D.currentProfile])yD[D.currentProfile]=KD.create(100,0,{stage:"Encode",name:D.currentProfile});let F=D.profilePercent??D.percent;yD[D.currentProfile].update(F,{stage:"Encode",name:D.currentProfile})}if(!vD)vD=KD.create(100,0,{stage:E,name:"Overall"});vD.update(D.percent,{stage:E,name:D.message||"Overall"})}});KD.stop(),console.log(`
✅ Conversion completed successfully!
`)}catch(u){KD.stop(),console.error(`
❌ Error during conversion:`),console.error(u),process.exit(1)}