UNPKG

ffmpeg-toolkit

Version:

A modern FFmpeg toolkit for Node.js

6 lines 353 kB
"use strict";var Ub=Object.create;var Ti=Object.defineProperty;var zb=Object.getOwnPropertyDescriptor;var Vb=Object.getOwnPropertyNames;var Bb=Object.getPrototypeOf,Hb=Object.prototype.hasOwnProperty;var k=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Gb=(t,e)=>{for(var r in e)Ti(t,r,{get:e[r],enumerable:!0})},tc=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vb(e))!Hb.call(t,i)&&i!==r&&Ti(t,i,{get:()=>e[i],enumerable:!(n=zb(e,i))||n.enumerable});return t};var We=(t,e,r)=>(r=t!=null?Ub(Bb(t)):{},tc(e||!t||!t.__esModule?Ti(r,"default",{value:t,enumerable:!0}):r,t)),Jb=t=>tc(Ti({},"__esModule",{value:!0}),t);var nc=k((jk,rc)=>{var Zb=require("fs");function Kb(t){try{var e=Zb.statSync(t);return e.isFile()}catch{return!1}}rc.exports=Kb});var ic=k((Yk,Qb)=>{Qb.exports={name:"@ffmpeg-installer/ffmpeg",version:"1.1.0",main:"index.js",scripts:{lint:"jshint *.js",preversion:"npm run lint",types:"tsc",preupload:"npm run types",upload:"npm --userconfig=.npmrc publish --access public",test:"tsd"},types:"types/index.d.ts",keywords:["ffmpeg","binary","installer","audio","sound"],author:"Kristoffer Lund\xE9n <kristoffer.lunden@gmail.com>",license:"LGPL-2.1",description:"Platform independent binary installer of FFmpeg for node projects",optionalDependencies:{"@ffmpeg-installer/darwin-arm64":"4.1.5","@ffmpeg-installer/darwin-x64":"4.1.0","@ffmpeg-installer/linux-arm":"4.1.3","@ffmpeg-installer/linux-arm64":"4.1.4","@ffmpeg-installer/linux-ia32":"4.1.0","@ffmpeg-installer/linux-x64":"4.1.0","@ffmpeg-installer/win32-ia32":"4.1.0","@ffmpeg-installer/win32-x64":"4.1.0"},devDependencies:{jshint:"^2.9.3",tsd:"^0.14.0",typescript:"^4.2.3"},repository:{type:"git",url:"git+https://github.com/kribblo/node-ffmpeg-installer.git"},bugs:{url:"https://github.com/kribblo/node-ffmpeg-installer/issues"},homepage:"https://github.com/kribblo/node-ffmpeg-installer#readme"}});var lc=k((Wk,uc)=>{"use strict";var qa=require("os"),Ft=require("path"),Pa=nc(),wn=qa.platform()+"-"+qa.arch(),Xb="@ffmpeg-installer/"+wn;if(!ic().optionalDependencies[Xb])throw"Unsupported platform/architecture: "+wn;var Na=qa.platform()==="win32"?"ffmpeg.exe":"ffmpeg",sc=Ft.resolve(__dirname.substr(0,__dirname.indexOf("node_modules")),"node_modules","@ffmpeg-installer",wn),ac=Ft.resolve(__dirname,"..",wn),oc=Ft.resolve(__dirname,"node_modules","@ffmpeg-installer",wn),Fa=Ft.join(sc,Na),Ra=Ft.join(ac,Na),Aa=Ft.join(oc,Na),e_=Ft.join(sc,"package.json"),t_=Ft.join(ac,"package.json"),r_=Ft.join(oc,"package.json"),ki,$r;if(Pa(Ra))ki=Ra,$r=require(t_);else if(Pa(Aa))ki=Aa,$r=require(r_);else if(Pa(Fa))ki=Fa,$r=require(e_);else throw'Could not find ffmpeg executable, tried "'+Ra+'", "'+Aa+'" and "'+Fa+'"';var n_=$r.ffmpeg||$r.version,i_=$r.homepage;uc.exports={path:ki,version:n_,url:i_}});var fc=k((Uk,cc)=>{var s_=require("node:fs");function a_(t){try{return s_.statSync(t).isFile()}catch{return!1}}cc.exports=a_});var hc=k((zk,o_)=>{o_.exports={name:"@ffprobe-installer/ffprobe",version:"2.1.2",main:"index.js",scripts:{lint:"xo",preversion:"npm run test",types:"tsc",test:"xo && nyc ava && nyc report --reporter=text-lcov > coverage.lcov && codecov -t 54b3d620-a296-4d71-a717-c3e6e24ae9d9",prepare:"npm run types && husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks"},types:"types/index.d.ts",keywords:["ffprobe","binary"],author:"Oliver Sayers <talk@savagecore.uk>",license:"LGPL-2.1",description:"Platform independent binary installer of FFprobe for node projects",files:["index.js","lib","platform","types","tsconfig.json"],optionalDependencies:{"@ffprobe-installer/darwin-arm64":"5.0.1","@ffprobe-installer/darwin-x64":"5.1.0","@ffprobe-installer/linux-arm":"5.2.0","@ffprobe-installer/linux-arm64":"5.2.0","@ffprobe-installer/linux-ia32":"5.2.0","@ffprobe-installer/linux-x64":"5.2.0","@ffprobe-installer/win32-ia32":"5.1.0","@ffprobe-installer/win32-x64":"5.1.0"},devDependencies:{ava:"^5.2.0",codecov:"^3.7.2",execa:"^8.0.1",executable:"^4.1.1",husky:"^8.0.3",nyc:"^15.1.0",shx:"^0.3.3",typescript:"^5.1.6",xo:"^0.56.0"},repository:{type:"git",url:"git+https://github.com/SavageCore/node-ffprobe-installer.git"},bugs:{url:"https://github.com/SavageCore/node-ffprobe-installer/issues"},homepage:"https://github.com/SavageCore/node-ffprobe-installer#readme",xo:{rules:{"unicorn/prefer-module":0,"unicorn/prefer-top-level-await":0}},engines:{node:">=14.21.2"}}});var vc=k((Vk,yc)=>{var dc=require("node:os"),pc=require("node:process"),u_=fc(),mc=pc.env.npm_config_platform||dc.platform(),l_=pc.env.npm_config_arch||dc.arch(),gc=mc+"-"+l_,Ia="@ffprobe-installer/"+gc;if(!hc().optionalDependencies[Ia])throw new Error("Unsupported platform/architecture: "+gc);var c_=mc==="win32"?"ffprobe.exe":"ffprobe",Ca=require.resolve(`${Ia}/${c_}`);if(!u_(Ca))throw new Error(`Could not find ffprobe executable, tried "${Ca}"`);var $a=require(`${Ia}/package.json`),f_=$a.ffprobe||$a.version,h_=$a.homepage;yc.exports={path:Ca,version:f_,url:h_}});var xc=k((Bk,Sc)=>{Sc.exports=_c;_c.sync=p_;var wc=require("fs");function d_(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&t.substr(-i.length).toLowerCase()===i)return!0}return!1}function bc(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:d_(e,r)}function _c(t,e,r){wc.stat(t,function(n,i){r(n,n?!1:bc(i,t,e))})}function p_(t,e){return bc(wc.statSync(t),t,e)}});var kc=k((Hk,Tc)=>{Tc.exports=Ec;Ec.sync=m_;var Oc=require("fs");function Ec(t,e,r){Oc.stat(t,function(n,i){r(n,n?!1:Mc(i,e))})}function m_(t,e){return Mc(Oc.statSync(t),e)}function Mc(t,e){return t.isFile()&&g_(t,e)}function g_(t,e){var r=t.mode,n=t.uid,i=t.gid,a=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),u=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),l=parseInt("100",8),h=parseInt("010",8),p=parseInt("001",8),m=l|h,y=r&p||r&h&&i===u||r&l&&n===a||r&m&&a===0;return y}});var Pc=k((Jk,Dc)=>{var Gk=require("fs"),Di;process.platform==="win32"||global.TESTING_WINDOWS?Di=xc():Di=kc();Dc.exports=La;La.sync=y_;function La(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){La(t,e||{},function(a,u){a?i(a):n(u)})})}Di(t,e||{},function(n,i){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function y_(t,e){try{return Di.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var $c=k((Zk,Cc)=>{Cc.exports=Nc;Nc.sync=w_;var ja=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Fc=require("path"),v_=ja?";":":",Rc=Pc();function Ac(t){var e=new Error("not found: "+t);return e.code="ENOENT",e}function qc(t,e){var r=e.colon||v_,n=e.path||process.env.PATH||"",i=[""];n=n.split(r);var a="";return ja&&(n.unshift(process.cwd()),a=e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM",i=a.split(r),t.indexOf(".")!==-1&&i[0]!==""&&i.unshift("")),(t.match(/\//)||ja&&t.match(/\\/))&&(n=[""]),{env:n,ext:i,extExe:a}}function Nc(t,e,r){typeof e=="function"&&(r=e,e={});var n=qc(t,e),i=n.env,a=n.ext,u=n.extExe,l=[];(function h(p,m){if(p===m)return e.all&&l.length?r(null,l):r(Ac(t));var y=i[p];y.charAt(0)==='"'&&y.slice(-1)==='"'&&(y=y.slice(1,-1));var v=Fc.join(y,t);!y&&/^\.[\\\/]/.test(t)&&(v=t.slice(0,2)+v),function b(g,T){if(g===T)return h(p+1,m);var D=a[g];Rc(v+D,{pathExt:u},function(N,j){if(!N&&j)if(e.all)l.push(v+D);else return r(null,v+D);return b(g+1,T)})}(0,a.length)})(0,i.length)}function w_(t,e){e=e||{};for(var r=qc(t,e),n=r.env,i=r.ext,a=r.extExe,u=[],l=0,h=n.length;l<h;l++){var p=n[l];p.charAt(0)==='"'&&p.slice(-1)==='"'&&(p=p.slice(1,-1));var m=Fc.join(p,t);!p&&/^\.[\\\/]/.test(t)&&(m=t.slice(0,2)+m);for(var y=0,v=i.length;y<v;y++){var b=m+i[y],g;try{if(g=Rc.sync(b,{pathExt:a}),g)if(e.all)u.push(b);else return b}catch{}}}if(e.all&&u.length)return u;if(e.nothrow)return null;throw Ac(t)}});var ft=k((Qk,Yc)=>{"use strict";var Kk=require("child_process").exec,b_=require("os").platform().match(/win(32|64)/),__=$c(),Ic=/\r\n|\r|\n/g,bn=/^\[?(.*?)\]?$/,Lc=/[,]/,Pi={};function S_(t){var e={};t=t.replace(/=\s+/g,"=").trim();for(var r=t.split(" "),n=0;n<r.length;n++){var i=r[n].split("=",2),a=i[0],u=i[1];if(typeof u>"u")return null;e[a]=u}return e}var jc=Yc.exports={isWindows:b_,streamRegexp:bn,copy:function(t,e){Object.keys(t).forEach(function(r){e[r]=t[r]})},args:function(){var t=[],e=function(){arguments.length===1&&Array.isArray(arguments[0])?t=t.concat(arguments[0]):t=t.concat([].slice.call(arguments))};return e.clear=function(){t=[]},e.get=function(){return t},e.find=function(r,n){var i=t.indexOf(r);if(i!==-1)return t.slice(i+1,i+1+(n||0))},e.remove=function(r,n){var i=t.indexOf(r);i!==-1&&t.splice(i,(n||0)+1)},e.clone=function(){var r=jc.args();return r(t),r},e},makeFilterStrings:function(t){return t.map(function(e){if(typeof e=="string")return e;var r="";return Array.isArray(e.inputs)?r+=e.inputs.map(function(n){return n.replace(bn,"[$1]")}).join(""):typeof e.inputs=="string"&&(r+=e.inputs.replace(bn,"[$1]")),r+=e.filter,e.options&&(typeof e.options=="string"||typeof e.options=="number"?r+="="+e.options:Array.isArray(e.options)?r+="="+e.options.map(function(n){return typeof n=="string"&&n.match(Lc)?"'"+n+"'":n}).join(":"):Object.keys(e.options).length&&(r+="="+Object.keys(e.options).map(function(n){var i=e.options[n];return typeof i=="string"&&i.match(Lc)&&(i="'"+i+"'"),n+"="+i}).join(":"))),Array.isArray(e.outputs)?r+=e.outputs.map(function(n){return n.replace(bn,"[$1]")}).join(""):typeof e.outputs=="string"&&(r+=e.outputs.replace(bn,"[$1]")),r})},which:function(t,e){if(t in Pi)return e(null,Pi[t]);__(t,function(r,n){if(r)return e(null,Pi[t]="");e(null,Pi[t]=n)})},timemarkToSeconds:function(t){if(typeof t=="number")return t;if(t.indexOf(":")===-1&&t.indexOf(".")>=0)return Number(t);var e=t.split(":"),r=Number(e.pop());return e.length&&(r+=Number(e.pop())*60),e.length&&(r+=Number(e.pop())*3600),r},extractCodecData:function(t,e,r){var n=/Input #[0-9]+, ([^ ]+),/,i=/Duration\: ([^,]+)/,a=/Audio\: (.*)/,u=/Video\: (.*)/;"inputStack"in r||(r.inputStack=[],r.inputIndex=-1,r.inInput=!1);var l=r.inputStack,h=r.inputIndex,p=r.inInput,m,y,v,b;if(m=e.match(n))p=r.inInput=!0,h=r.inputIndex=r.inputIndex+1,l[h]={format:m[1],audio:"",video:"",duration:""};else if(p&&(y=e.match(i)))l[h].duration=y[1];else if(p&&(v=e.match(a)))v=v[1].split(", "),l[h].audio=v[0],l[h].audio_details=v;else if(p&&(b=e.match(u)))b=b[1].split(", "),l[h].video=b[0],l[h].video_details=b;else if(/Output #\d+/.test(e))p=r.inInput=!1;else if(/Stream mapping:|Press (\[q\]|ctrl-c) to stop/.test(e))return t.emit.apply(t,["codecData"].concat(l)),!0;return!1},extractProgress:function(t,e){var r=S_(e);if(r){var n={frames:parseInt(r.frame,10),currentFps:parseInt(r.fps,10),currentKbps:r.bitrate?parseFloat(r.bitrate.replace("kbits/s","")):0,targetSize:parseInt(r.size||r.Lsize,10),timemark:r.time};if(t._ffprobeData&&t._ffprobeData.format&&t._ffprobeData.format.duration){var i=Number(t._ffprobeData.format.duration);isNaN(i)||(n.percent=jc.timemarkToSeconds(n.timemark)/i*100)}t.emit("progress",n)}},extractError:function(t){return t.split(Ic).reduce(function(e,r){return r.charAt(0)===" "||r.charAt(0)==="["?[]:(e.push(r),e)},[]).join(` `)},linesRing:function(t){var e=[],r=[],n=null,i=!1,a=t-1;function u(l){e.forEach(function(h){h(l)})}return{callback:function(l){r.forEach(function(h){l(h)}),e.push(l)},append:function(l){if(!i&&(l instanceof Buffer&&(l=""+l),!(!l||l.length===0))){var h=l.split(Ic);h.length===1?n!==null?n=n+h.shift():n=h.shift():(n!==null&&(n=n+h.shift(),u(n),r.push(n)),n=h.pop(),h.forEach(function(p){u(p),r.push(p)}),a>-1&&r.length>a&&r.splice(0,r.length-a))}},get:function(){return n!==null?r.concat([n]).join(` `):r.join(` `)},close:function(){i||(n!==null&&(u(n),r.push(n),a>-1&&r.length>a&&r.shift(),n=null),i=!0)}}}}});var Uc=k((Xk,Wc)=>{"use strict";var x_=ft();Wc.exports=function(t){t.mergeAdd=t.addInput=t.input=function(e){var r=!1,n=!1;if(typeof e!="string"){if(!("readable"in e)||!e.readable)throw new Error("Invalid input");var i=this._inputs.some(function(u){return u.isStream});if(i)throw new Error("Only one input stream is supported");n=!0,e.pause()}else{var a=e.match(/^([a-z]{2,}):/i);r=!a||a[0]==="file"}return this._inputs.push(this._currentInput={source:e,isFile:r,isStream:n,options:x_.args()}),this},t.withInputFormat=t.inputFormat=t.fromFormat=function(e){if(!this._currentInput)throw new Error("No input specified");return this._currentInput.options("-f",e),this},t.withInputFps=t.withInputFPS=t.withFpsInput=t.withFPSInput=t.inputFPS=t.inputFps=t.fpsInput=t.FPSInput=function(e){if(!this._currentInput)throw new Error("No input specified");return this._currentInput.options("-r",e),this},t.nativeFramerate=t.withNativeFramerate=t.native=function(){if(!this._currentInput)throw new Error("No input specified");return this._currentInput.options("-re"),this},t.setStartTime=t.seekInput=function(e){if(!this._currentInput)throw new Error("No input specified");return this._currentInput.options("-ss",e),this},t.loop=function(e){if(!this._currentInput)throw new Error("No input specified");return this._currentInput.options("-loop","1"),typeof e<"u"&&this.duration(e),this}}});var Vc=k((eD,zc)=>{"use strict";var O_=ft();zc.exports=function(t){t.withNoAudio=t.noAudio=function(){return this._currentOutput.audio.clear(),this._currentOutput.audioFilters.clear(),this._currentOutput.audio("-an"),this},t.withAudioCodec=t.audioCodec=function(e){return this._currentOutput.audio("-acodec",e),this},t.withAudioBitrate=t.audioBitrate=function(e){return this._currentOutput.audio("-b:a",(""+e).replace(/k?$/,"k")),this},t.withAudioChannels=t.audioChannels=function(e){return this._currentOutput.audio("-ac",e),this},t.withAudioFrequency=t.audioFrequency=function(e){return this._currentOutput.audio("-ar",e),this},t.withAudioQuality=t.audioQuality=function(e){return this._currentOutput.audio("-aq",e),this},t.withAudioFilter=t.withAudioFilters=t.audioFilter=t.audioFilters=function(e){return arguments.length>1&&(e=[].slice.call(arguments)),Array.isArray(e)||(e=[e]),this._currentOutput.audioFilters(O_.makeFilterStrings(e)),this}}});var Hc=k((tD,Bc)=>{"use strict";var E_=ft();Bc.exports=function(t){t.withNoVideo=t.noVideo=function(){return this._currentOutput.video.clear(),this._currentOutput.videoFilters.clear(),this._currentOutput.video("-vn"),this},t.withVideoCodec=t.videoCodec=function(e){return this._currentOutput.video("-vcodec",e),this},t.withVideoBitrate=t.videoBitrate=function(e,r){return e=(""+e).replace(/k?$/,"k"),this._currentOutput.video("-b:v",e),r&&this._currentOutput.video("-maxrate",e,"-minrate",e,"-bufsize","3M"),this},t.withVideoFilter=t.withVideoFilters=t.videoFilter=t.videoFilters=function(e){return arguments.length>1&&(e=[].slice.call(arguments)),Array.isArray(e)||(e=[e]),this._currentOutput.videoFilters(E_.makeFilterStrings(e)),this},t.withOutputFps=t.withOutputFPS=t.withFpsOutput=t.withFPSOutput=t.withFps=t.withFPS=t.outputFPS=t.outputFps=t.fpsOutput=t.FPSOutput=t.fps=t.FPS=function(e){return this._currentOutput.video("-r",e),this},t.takeFrames=t.withFrames=t.frames=function(e){return this._currentOutput.video("-vframes",e),this}}});var Zc=k((rD,Jc)=>{"use strict";function Gc(t,e,r,n){return[{filter:"scale",options:{w:"if(gt(a,"+r+"),"+t+",trunc("+e+"*a/2)*2)",h:"if(lt(a,"+r+"),"+e+",trunc("+t+"/a/2)*2)"}},{filter:"pad",options:{w:t,h:e,x:"if(gt(a,"+r+"),0,("+t+"-iw)/2)",y:"if(lt(a,"+r+"),0,("+e+"-ih)/2)",color:n}}]}function Ya(t,e,r){var n=t.sizeData=t.sizeData||{};if(n[e]=r,!("size"in n))return[];var i=n.size.match(/([0-9]+)x([0-9]+)/),a=n.size.match(/([0-9]+)x\?/),u=n.size.match(/\?x([0-9]+)/),l=n.size.match(/\b([0-9]{1,3})%/),h,p,m;if(l){var y=Number(l[1])/100;return[{filter:"scale",options:{w:"trunc(iw*"+y+"/2)*2",h:"trunc(ih*"+y+"/2)*2"}}]}else{if(i)return h=Math.round(Number(i[1])/2)*2,p=Math.round(Number(i[2])/2)*2,m=h/p,n.pad?Gc(h,p,m,n.pad):[{filter:"scale",options:{w:h,h:p}}];if(a||u)return"aspect"in n?(h=a?a[1]:Math.round(Number(u[1])*n.aspect),p=u?u[1]:Math.round(Number(a[1])/n.aspect),h=Math.round(h/2)*2,p=Math.round(p/2)*2,n.pad?Gc(h,p,n.aspect,n.pad):[{filter:"scale",options:{w:h,h:p}}]):a?[{filter:"scale",options:{w:Math.round(Number(a[1])/2)*2,h:"trunc(ow/a/2)*2"}}]:[{filter:"scale",options:{w:"trunc(oh*a/2)*2",h:Math.round(Number(u[1])/2)*2}}];throw new Error("Invalid size specified: "+n.size)}}Jc.exports=function(t){t.keepPixelAspect=t.keepDisplayAspect=t.keepDisplayAspectRatio=t.keepDAR=function(){return this.videoFilters([{filter:"scale",options:{w:"if(gt(sar,1),iw*sar,iw)",h:"if(lt(sar,1),ih/sar,ih)"}},{filter:"setsar",options:"1"}])},t.withSize=t.setSize=t.size=function(e){var r=Ya(this._currentOutput,"size",e);return this._currentOutput.sizeFilters.clear(),this._currentOutput.sizeFilters(r),this},t.withAspect=t.withAspectRatio=t.setAspect=t.setAspectRatio=t.aspect=t.aspectRatio=function(e){var r=Number(e);if(isNaN(r)){var n=e.match(/^(\d+):(\d+)$/);if(n)r=Number(n[1])/Number(n[2]);else throw new Error("Invalid aspect ratio: "+e)}var i=Ya(this._currentOutput,"aspect",r);return this._currentOutput.sizeFilters.clear(),this._currentOutput.sizeFilters(i),this},t.applyAutopadding=t.applyAutoPadding=t.applyAutopad=t.applyAutoPad=t.withAutopadding=t.withAutoPadding=t.withAutopad=t.withAutoPad=t.autoPad=t.autopad=function(e,r){typeof e=="string"&&(r=e,e=!0),typeof e>"u"&&(e=!0);var n=Ya(this._currentOutput,"pad",e?r||"black":!1);return this._currentOutput.sizeFilters.clear(),this._currentOutput.sizeFilters(n),this}}});var Xc=k((nD,Qc)=>{"use strict";var Kc=ft();Qc.exports=function(t){t.addOutput=t.output=function(e,r){var n=!1;if(!e&&this._currentOutput)throw new Error("Invalid output");if(e&&typeof e!="string"){if(!("writable"in e)||!e.writable)throw new Error("Invalid output")}else if(typeof e=="string"){var i=e.match(/^([a-z]{2,}):/i);n=!i||i[0]==="file"}if(e&&!("target"in this._currentOutput))this._currentOutput.target=e,this._currentOutput.isFile=n,this._currentOutput.pipeopts=r||{};else{if(e&&typeof e!="string"){var a=this._outputs.some(function(l){return typeof l.target!="string"});if(a)throw new Error("Only one output stream is supported")}this._outputs.push(this._currentOutput={target:e,isFile:n,flags:{},pipeopts:r||{}});var u=this;["audio","audioFilters","video","videoFilters","sizeFilters","options"].forEach(function(l){u._currentOutput[l]=Kc.args()}),e||delete this._currentOutput.target}return this},t.seekOutput=t.seek=function(e){return this._currentOutput.options("-ss",e),this},t.withDuration=t.setDuration=t.duration=function(e){return this._currentOutput.options("-t",e),this},t.toFormat=t.withOutputFormat=t.outputFormat=t.format=function(e){return this._currentOutput.options("-f",e),this},t.map=function(e){return this._currentOutput.options("-map",e.replace(Kc.streamRegexp,"[$1]")),this},t.updateFlvMetadata=t.flvmeta=function(){return this._currentOutput.flags.flvmeta=!0,this}}});var tf=k((iD,ef)=>{"use strict";var Wa=ft();ef.exports=function(t){t.addInputOption=t.addInputOptions=t.withInputOption=t.withInputOptions=t.inputOption=t.inputOptions=function(e){if(!this._currentInput)throw new Error("No input specified");var r=!0;return arguments.length>1&&(e=[].slice.call(arguments),r=!1),Array.isArray(e)||(e=[e]),this._currentInput.options(e.reduce(function(n,i){var a=String(i).split(" ");return r&&a.length===2?n.push(a[0],a[1]):n.push(i),n},[])),this},t.addOutputOption=t.addOutputOptions=t.addOption=t.addOptions=t.withOutputOption=t.withOutputOptions=t.withOption=t.withOptions=t.outputOption=t.outputOptions=function(e){var r=!0;return arguments.length>1&&(e=[].slice.call(arguments),r=!1),Array.isArray(e)||(e=[e]),this._currentOutput.options(e.reduce(function(n,i){var a=String(i).split(" ");return r&&a.length===2?n.push(a[0],a[1]):n.push(i),n},[])),this},t.filterGraph=t.complexFilter=function(e,r){if(this._complexFilters.clear(),Array.isArray(e)||(e=[e]),this._complexFilters("-filter_complex",Wa.makeFilterStrings(e).join(";")),Array.isArray(r)){var n=this;r.forEach(function(i){n._complexFilters("-map",i.replace(Wa.streamRegexp,"[$1]"))})}else typeof r=="string"&&this._complexFilters("-map",r.replace(Wa.streamRegexp,"[$1]"));return this}}});var nf=k((sD,rf)=>{"use strict";var M_=require("path");rf.exports=function(t){t.usingPreset=t.preset=function(e){if(typeof e=="function")e(this);else try{var r=M_.join(this.options.presets,e),n=require(r);if(typeof n.load=="function")n.load(this);else throw new Error("preset "+r+" has no load() function")}catch(i){throw new Error("preset "+r+" could not be loaded: "+i.message)}return this}}});var Ri=k((aD,Fi)=>{(function(){var t={},e,r;e=this,e!=null&&(r=e.async),t.noConflict=function(){return e.async=r,t};function n(x){var _=!1;return function(){if(_)throw new Error("Callback was already called.");_=!0,x.apply(e,arguments)}}var i=function(x,_){if(x.forEach)return x.forEach(_);for(var M=0;M<x.length;M+=1)_(x[M],M,x)},a=function(x,_){if(x.map)return x.map(_);var M=[];return i(x,function(O,w,P){M.push(_(O,w,P))}),M},u=function(x,_,M){return x.reduce?x.reduce(_,M):(i(x,function(O,w,P){M=_(M,O,w,P)}),M)},l=function(x){if(Object.keys)return Object.keys(x);var _=[];for(var M in x)x.hasOwnProperty(M)&&_.push(M);return _};typeof process>"u"||!process.nextTick?typeof setImmediate=="function"?(t.nextTick=function(x){setImmediate(x)},t.setImmediate=t.nextTick):(t.nextTick=function(x){setTimeout(x,0)},t.setImmediate=t.nextTick):(t.nextTick=process.nextTick,typeof setImmediate<"u"?t.setImmediate=function(x){setImmediate(x)}:t.setImmediate=t.nextTick),t.each=function(x,_,M){if(M=M||function(){},!x.length)return M();var O=0;i(x,function(w){_(w,n(function(P){P?(M(P),M=function(){}):(O+=1,O>=x.length&&M(null))}))})},t.forEach=t.each,t.eachSeries=function(x,_,M){if(M=M||function(){},!x.length)return M();var O=0,w=function(){_(x[O],function(P){P?(M(P),M=function(){}):(O+=1,O>=x.length?M(null):w())})};w()},t.forEachSeries=t.eachSeries,t.eachLimit=function(x,_,M,O){var w=h(_);w.apply(null,[x,M,O])},t.forEachLimit=t.eachLimit;var h=function(x){return function(_,M,O){if(O=O||function(){},!_.length||x<=0)return O();var w=0,P=0,R=0;(function q(){if(w>=_.length)return O();for(;R<x&&P<_.length;)P+=1,R+=1,M(_[P-1],function(A){A?(O(A),O=function(){}):(w+=1,R-=1,w>=_.length?O():q())})})()}},p=function(x){return function(){var _=Array.prototype.slice.call(arguments);return x.apply(null,[t.each].concat(_))}},m=function(x,_){return function(){var M=Array.prototype.slice.call(arguments);return _.apply(null,[h(x)].concat(M))}},y=function(x){return function(){var _=Array.prototype.slice.call(arguments);return x.apply(null,[t.eachSeries].concat(_))}},v=function(x,_,M,O){var w=[];_=a(_,function(P,R){return{index:R,value:P}}),x(_,function(P,R){M(P.value,function(q,A){w[P.index]=A,R(q)})},function(P){O(P,w)})};t.map=p(v),t.mapSeries=y(v),t.mapLimit=function(x,_,M,O){return b(_)(x,M,O)};var b=function(x){return m(x,v)};t.reduce=function(x,_,M,O){t.eachSeries(x,function(w,P){M(_,w,function(R,q){_=q,P(R)})},function(w){O(w,_)})},t.inject=t.reduce,t.foldl=t.reduce,t.reduceRight=function(x,_,M,O){var w=a(x,function(P){return P}).reverse();t.reduce(w,_,M,O)},t.foldr=t.reduceRight;var g=function(x,_,M,O){var w=[];_=a(_,function(P,R){return{index:R,value:P}}),x(_,function(P,R){M(P.value,function(q){q&&w.push(P),R()})},function(P){O(a(w.sort(function(R,q){return R.index-q.index}),function(R){return R.value}))})};t.filter=p(g),t.filterSeries=y(g),t.select=t.filter,t.selectSeries=t.filterSeries;var T=function(x,_,M,O){var w=[];_=a(_,function(P,R){return{index:R,value:P}}),x(_,function(P,R){M(P.value,function(q){q||w.push(P),R()})},function(P){O(a(w.sort(function(R,q){return R.index-q.index}),function(R){return R.value}))})};t.reject=p(T),t.rejectSeries=y(T);var D=function(x,_,M,O){x(_,function(w,P){M(w,function(R){R?(O(w),O=function(){}):P()})},function(w){O()})};t.detect=p(D),t.detectSeries=y(D),t.some=function(x,_,M){t.each(x,function(O,w){_(O,function(P){P&&(M(!0),M=function(){}),w()})},function(O){M(!1)})},t.any=t.some,t.every=function(x,_,M){t.each(x,function(O,w){_(O,function(P){P||(M(!1),M=function(){}),w()})},function(O){M(!0)})},t.all=t.every,t.sortBy=function(x,_,M){t.map(x,function(O,w){_(O,function(P,R){P?w(P):w(null,{value:O,criteria:R})})},function(O,w){if(O)return M(O);var P=function(R,q){var A=R.criteria,I=q.criteria;return A<I?-1:A>I?1:0};M(null,a(w.sort(P),function(R){return R.value}))})},t.auto=function(x,_){_=_||function(){};var M=l(x);if(!M.length)return _(null);var O={},w=[],P=function(A){w.unshift(A)},R=function(A){for(var I=0;I<w.length;I+=1)if(w[I]===A){w.splice(I,1);return}},q=function(){i(w.slice(0),function(A){A()})};P(function(){l(O).length===M.length&&(_(null,O),_=function(){})}),i(M,function(A){var I=x[A]instanceof Function?[x[A]]:x[A],W=function(V){var z=Array.prototype.slice.call(arguments,1);if(z.length<=1&&(z=z[0]),V){var Q={};i(l(O),function(ne){Q[ne]=O[ne]}),Q[A]=z,_(V,Q),_=function(){}}else O[A]=z,t.setImmediate(q)},E=I.slice(0,Math.abs(I.length-1))||[],C=function(){return u(E,function(V,z){return V&&O.hasOwnProperty(z)},!0)&&!O.hasOwnProperty(A)};if(C())I[I.length-1](W,O);else{var Y=function(){C()&&(R(Y),I[I.length-1](W,O))};P(Y)}})},t.waterfall=function(x,_){if(_=_||function(){},x.constructor!==Array){var M=new Error("First argument to waterfall must be an array of functions");return _(M)}if(!x.length)return _();var O=function(w){return function(P){if(P)_.apply(null,arguments),_=function(){};else{var R=Array.prototype.slice.call(arguments,1),q=w.next();q?R.push(O(q)):R.push(_),t.setImmediate(function(){w.apply(null,R)})}}};O(t.iterator(x))()};var N=function(x,_,M){if(M=M||function(){},_.constructor===Array)x.map(_,function(w,P){w&&w(function(R){var q=Array.prototype.slice.call(arguments,1);q.length<=1&&(q=q[0]),P.call(null,R,q)})},M);else{var O={};x.each(l(_),function(w,P){_[w](function(R){var q=Array.prototype.slice.call(arguments,1);q.length<=1&&(q=q[0]),O[w]=q,P(R)})},function(w){M(w,O)})}};t.parallel=function(x,_){N({map:t.map,each:t.each},x,_)},t.parallelLimit=function(x,_,M){N({map:b(_),each:h(_)},x,M)},t.series=function(x,_){if(_=_||function(){},x.constructor===Array)t.mapSeries(x,function(O,w){O&&O(function(P){var R=Array.prototype.slice.call(arguments,1);R.length<=1&&(R=R[0]),w.call(null,P,R)})},_);else{var M={};t.eachSeries(l(x),function(O,w){x[O](function(P){var R=Array.prototype.slice.call(arguments,1);R.length<=1&&(R=R[0]),M[O]=R,w(P)})},function(O){_(O,M)})}},t.iterator=function(x){var _=function(M){var O=function(){return x.length&&x[M].apply(null,arguments),O.next()};return O.next=function(){return M<x.length-1?_(M+1):null},O};return _(0)},t.apply=function(x){var _=Array.prototype.slice.call(arguments,1);return function(){return x.apply(null,_.concat(Array.prototype.slice.call(arguments)))}};var j=function(x,_,M,O){var w=[];x(_,function(P,R){M(P,function(q,A){w=w.concat(A||[]),R(q)})},function(P){O(P,w)})};t.concat=p(j),t.concatSeries=y(j),t.whilst=function(x,_,M){x()?_(function(O){if(O)return M(O);t.whilst(x,_,M)}):M()},t.doWhilst=function(x,_,M){x(function(O){if(O)return M(O);_()?t.doWhilst(x,_,M):M()})},t.until=function(x,_,M){x()?M():_(function(O){if(O)return M(O);t.until(x,_,M)})},t.doUntil=function(x,_,M){x(function(O){if(O)return M(O);_()?M():t.doUntil(x,_,M)})},t.queue=function(x,_){_===void 0&&(_=1);function M(P,R,q,A){R.constructor!==Array&&(R=[R]),i(R,function(I){var W={data:I,callback:typeof A=="function"?A:null};q?P.tasks.unshift(W):P.tasks.push(W),P.saturated&&P.tasks.length===_&&P.saturated(),t.setImmediate(P.process)})}var O=0,w={tasks:[],concurrency:_,saturated:null,empty:null,drain:null,push:function(P,R){M(w,P,!1,R)},unshift:function(P,R){M(w,P,!0,R)},process:function(){if(O<w.concurrency&&w.tasks.length){var P=w.tasks.shift();w.empty&&w.tasks.length===0&&w.empty(),O+=1;var R=function(){O-=1,P.callback&&P.callback.apply(P,arguments),w.drain&&w.tasks.length+O===0&&w.drain(),w.process()},q=n(R);x(P.data,q)}},length:function(){return w.tasks.length},running:function(){return O}};return w},t.cargo=function(x,_){var M=!1,O=[],w={tasks:O,payload:_,saturated:null,empty:null,drain:null,push:function(P,R){P.constructor!==Array&&(P=[P]),i(P,function(q){O.push({data:q,callback:typeof R=="function"?R:null}),w.saturated&&O.length===_&&w.saturated()}),t.setImmediate(w.process)},process:function P(){if(!M){if(O.length===0){w.drain&&w.drain();return}var R=typeof _=="number"?O.splice(0,_):O.splice(0),q=a(R,function(A){return A.data});w.empty&&w.empty(),M=!0,x(q,function(){M=!1;var A=arguments;i(R,function(I){I.callback&&I.callback.apply(null,A)}),P()})}},length:function(){return O.length},running:function(){return M}};return w};var F=function(x){return function(_){var M=Array.prototype.slice.call(arguments,1);_.apply(null,M.concat([function(O){var w=Array.prototype.slice.call(arguments,1);typeof console<"u"&&(O?console.error&&console.error(O):console[x]&&i(w,function(P){console[x](P)}))}]))}};t.log=F("log"),t.dir=F("dir"),t.memoize=function(x,_){var M={},O={};_=_||function(P){return P};var w=function(){var P=Array.prototype.slice.call(arguments),R=P.pop(),q=_.apply(null,P);q in M?R.apply(null,M[q]):q in O?O[q].push(R):(O[q]=[R],x.apply(null,P.concat([function(){M[q]=arguments;var A=O[q];delete O[q];for(var I=0,W=A.length;I<W;I++)A[I].apply(null,arguments)}])))};return w.memo=M,w.unmemoized=x,w},t.unmemoize=function(x){return function(){return(x.unmemoized||x).apply(null,arguments)}},t.times=function(x,_,M){for(var O=[],w=0;w<x;w++)O.push(w);return t.map(O,_,M)},t.timesSeries=function(x,_,M){for(var O=[],w=0;w<x;w++)O.push(w);return t.mapSeries(O,_,M)},t.compose=function(){var x=Array.prototype.reverse.call(arguments);return function(){var _=this,M=Array.prototype.slice.call(arguments),O=M.pop();t.reduce(x,M,function(w,P,R){P.apply(_,w.concat([function(){var q=arguments[0],A=Array.prototype.slice.call(arguments,1);R(q,A)}]))},function(w,P){O.apply(_,[w].concat(P))})}};var L=function(x,_){var M=function(){var w=this,P=Array.prototype.slice.call(arguments),R=P.pop();return x(_,function(q,A){q.apply(w,P.concat([A]))},R)};if(arguments.length>2){var O=Array.prototype.slice.call(arguments,2);return M.apply(this,O)}else return M};t.applyEach=p(L),t.applyEachSeries=y(L),t.forever=function(x,_){function M(O){if(O){if(_)return _(O);throw O}x(M)}M()},typeof define<"u"&&define.amd?define([],function(){return t}):typeof Fi<"u"&&Fi.exports?Fi.exports=t:e.async=t})()});var uf=k((lD,of)=>{"use strict";var Ua=require("child_process").spawn,oD=require("path"),uD=require("fs"),sf=Ri(),Yt=ft();function af(t){t._inputs[0].isStream||t.ffprobe(0,function(r,n){t._ffprobeData=n})}of.exports=function(t){t._spawnFfmpeg=function(e,r,n,i){typeof r=="function"&&(i=n,n=r,r={}),typeof i>"u"&&(i=n,n=function(){});var a="stdoutLines"in r?r.stdoutLines:this.options.stdoutLines;this._getFfmpegPath(function(u,l){if(u)return i(u);if(!l||l.length===0)return i(new Error("Cannot find ffmpeg"));r.niceness&&r.niceness!==0&&!Yt.isWindows&&(e.unshift("-n",r.niceness,l),l="nice");var h=Yt.linesRing(a),p=!1,m=Yt.linesRing(a),y=!1,v=Ua(l,e,r);v.stderr&&v.stderr.setEncoding("utf8"),v.on("error",function(D){i(D)});var b=null;function g(D){D&&(b=D),T&&(p||!r.captureStdout)&&y&&i(b,h,m)}var T=!1;v.on("exit",function(D,N){T=!0,N?g(new Error("ffmpeg was killed with signal "+N)):D?g(new Error("ffmpeg exited with code "+D)):g()}),r.captureStdout&&(v.stdout.on("data",function(D){h.append(D)}),v.stdout.on("close",function(){h.close(),p=!0,g()})),v.stderr.on("data",function(D){m.append(D)}),v.stderr.on("close",function(){m.close(),y=!0,g()}),n(v,h,m)})},t._getArguments=function(){var e=this._complexFilters.get(),r=this._outputs.some(function(n){return n.isFile});return[].concat(this._inputs.reduce(function(n,i){var a=typeof i.source=="string"?i.source:"pipe:0";return n.concat(i.options.get(),["-i",a])},[]),this._global.get(),r?["-y"]:[],e,this._outputs.reduce(function(n,i){var a=Yt.makeFilterStrings(i.sizeFilters.get()),u=i.audioFilters.get(),l=i.videoFilters.get().concat(a),h;return i.target?typeof i.target=="string"?h=[i.target]:h=["pipe:1"]:h=[],n.concat(i.audio.get(),u.length?["-filter:a",u.join(",")]:[],i.video.get(),l.length?["-filter:v",l.join(",")]:[],i.options.get(),h)},[]))},t._prepare=function(e,r){var n=this;sf.waterfall([function(i){n._checkCapabilities(i)},function(i){if(!r)return i();n.ffprobe(0,function(a,u){a||(n._ffprobeData=u),i()})},function(i){var a=n._outputs.some(function(u){return u.flags.flvmeta&&!u.isFile&&(n.logger.warn("Updating flv metadata is only supported for files"),u.flags.flvmeta=!1),u.flags.flvmeta});a?n._getFlvtoolPath(function(u){i(u)}):i()},function(i){var a;try{a=n._getArguments()}catch(u){return i(u)}i(null,a)},function(i,a){n.availableEncoders(function(u,l){for(var h=0;h<i.length;h++)(i[h]==="-acodec"||i[h]==="-vcodec")&&(h++,i[h]in l&&l[i[h]].experimental&&(i.splice(h+1,0,"-strict","experimental"),h+=2));a(null,i)})}],e),r||(this.listeners("progress").length>0?af(this):this.once("newListener",function(i){i==="progress"&&af(this)}))},t.exec=t.execute=t.run=function(){var e=this,r=this._outputs.some(function(l){return"target"in l});if(!r)throw new Error("No output specified");var n=this._outputs.filter(function(l){return typeof l.target!="string"})[0],i=this._inputs.filter(function(l){return typeof l.source!="string"})[0],a=!1;function u(l,h,p){a||(a=!0,l?e.emit("error",l,h,p):e.emit("end",h,p))}return e._prepare(function(l,h){if(l)return u(l);e._spawnFfmpeg(h,{captureStdout:!n,niceness:e.options.niceness,cwd:e.options.cwd,windowsHide:!0},function(m,y,v){if(e.ffmpegProc=m,e.emit("start","ffmpeg "+h.join(" ")),i&&(i.source.on("error",function(T){var D=new Error("Input stream error: "+T.message);D.inputStreamError=T,u(D),m.kill()}),i.source.resume(),i.source.pipe(m.stdin),m.stdin.on("error",function(){})),e.options.timeout&&(e.processTimer=setTimeout(function(){var T="process ran into a timeout ("+e.options.timeout+"s)";u(new Error(T),y.get(),v.get()),m.kill()},e.options.timeout*1e3)),n&&(m.stdout.pipe(n.target,n.pipeopts),n.target.on("close",function(){e.logger.debug("Output stream closed, scheduling kill for ffmpeg process"),setTimeout(function(){u(new Error("Output stream closed")),m.kill()},20)}),n.target.on("error",function(T){e.logger.debug("Output stream error, killing ffmpeg process");var D=new Error("Output stream error: "+T.message);D.outputStreamError=T,u(D,y.get(),v.get()),m.kill("SIGKILL")})),v){if(e.listeners("stderr").length&&v.callback(function(T){e.emit("stderr",T)}),e.listeners("codecData").length){var b=!1,g={};v.callback(function(T){b||(b=Yt.extractCodecData(e,T,g))})}e.listeners("progress").length&&v.callback(function(T){Yt.extractProgress(e,T)})}},function(m,y,v){if(clearTimeout(e.processTimer),delete e.ffmpegProc,m)m.message.match(/ffmpeg exited with code/)&&(m.message+=": "+Yt.extractError(v.get())),u(m,y.get(),v.get());else{var b=e._outputs.filter(function(g){return g.flags.flvmeta});b.length?e._getFlvtoolPath(function(g,T){if(g)return u(g);sf.each(b,function(D,N){Ua(T,["-U",D.target],{windowsHide:!0}).on("error",function(j){N(new Error("Error running "+T+" on "+D.target+": "+j.message))}).on("exit",function(j,F){j!==0||F?N(new Error(T+" "+(F?"received signal "+F:"exited with code "+j))+" when running on "+D.target):N()})},function(D){D?u(D):u(null,y.get(),v.get())})}):u(null,y.get(),v.get())}})}),this},t.renice=function(e){if(!Yt.isWindows&&(e=e||0,(e<-20||e>20)&&this.logger.warn("Invalid niceness value: "+e+", must be between -20 and 20"),e=Math.min(20,Math.max(-20,e)),this.options.niceness=e,this.ffmpegProc)){var r=this.logger,n=this.ffmpegProc.pid,i=Ua("renice",[e,"-p",n],{windowsHide:!0});i.on("error",function(a){r.warn("could not renice process "+n+": "+a.message)}),i.on("exit",function(a,u){u?r.warn("could not renice process "+n+": renice was killed by signal "+u):a?r.warn("could not renice process "+n+": renice exited with "+a):r.info("successfully reniced process "+n+" to "+e+" niceness")})}return this},t.kill=function(e){return this.ffmpegProc?this.ffmpegProc.kill(e||"SIGKILL"):this.logger.warn("No running ffmpeg process, cannot send signal"),this}}});var ff=k((cD,cf)=>{"use strict";var _n=require("fs"),lf=require("path"),Ai=Ri(),Wt=ft(),T_=/^\s*([D ])([E ])([VAS])([S ])([D ])([T ]) ([^ ]+) +(.*)$/,k_=/^\s*([D\.])([E\.])([VAS])([I\.])([L\.])([S\.]) ([^ ]+) +(.*)$/,D_=/\(encoders:([^\)]+)\)/,P_=/\(decoders:([^\)]+)\)/,F_=/^\s*([VAS\.])([F\.])([S\.])([X\.])([B\.])([D\.]) ([^ ]+) +(.*)$/,R_=/^\s*([D ])([E ])\s+([^ ]+)\s+(.*)$/,za=/\r\n|\r|\n/,A_=/^(?: [T\.][S\.][C\.] )?([^ ]+) +(AA?|VV?|\|)->(AA?|VV?|\|) +(.*)$/,le={};cf.exports=function(t){t.setFfmpegPath=function(e){return le.ffmpegPath=e,this},t.setFfprobePath=function(e){return le.ffprobePath=e,this},t.setFlvtoolPath=function(e){return le.flvtoolPath=e,this},t._forgetPaths=function(){delete le.ffmpegPath,delete le.ffprobePath,delete le.flvtoolPath},t._getFfmpegPath=function(e){if("ffmpegPath"in le)return e(null,le.ffmpegPath);Ai.waterfall([function(r){process.env.FFMPEG_PATH?_n.exists(process.env.FFMPEG_PATH,function(n){n?r(null,process.env.FFMPEG_PATH):r(null,"")}):r(null,"")},function(r,n){if(r.length)return n(null,r);Wt.which("ffmpeg",function(i,a){n(i,a)})}],function(r,n){r?e(r):e(null,le.ffmpegPath=n||"")})},t._getFfprobePath=function(e){var r=this;if("ffprobePath"in le)return e(null,le.ffprobePath);Ai.waterfall([function(n){process.env.FFPROBE_PATH?_n.exists(process.env.FFPROBE_PATH,function(i){n(null,i?process.env.FFPROBE_PATH:"")}):n(null,"")},function(n,i){if(n.length)return i(null,n);Wt.which("ffprobe",function(a,u){i(a,u)})},function(n,i){if(n.length)return i(null,n);r._getFfmpegPath(function(a,u){if(a)i(a);else if(u.length){var l=Wt.isWindows?"ffprobe.exe":"ffprobe",h=lf.join(lf.dirname(u),l);_n.exists(h,function(p){i(null,p?h:"")})}else i(null,"")})}],function(n,i){n?e(n):e(null,le.ffprobePath=i||"")})},t._getFlvtoolPath=function(e){if("flvtoolPath"in le)return e(null,le.flvtoolPath);Ai.waterfall([function(r){process.env.FLVMETA_PATH?_n.exists(process.env.FLVMETA_PATH,function(n){r(null,n?process.env.FLVMETA_PATH:"")}):r(null,"")},function(r,n){if(r.length)return n(null,r);process.env.FLVTOOL2_PATH?_n.exists(process.env.FLVTOOL2_PATH,function(i){n(null,i?process.env.FLVTOOL2_PATH:"")}):n(null,"")},function(r,n){if(r.length)return n(null,r);Wt.which("flvmeta",function(i,a){n(i,a)})},function(r,n){if(r.length)return n(null,r);Wt.which("flvtool2",function(i,a){n(i,a)})}],function(r,n){r?e(r):e(null,le.flvtoolPath=n||"")})},t.availableFilters=t.getAvailableFilters=function(e){if("filters"in le)return e(null,le.filters);this._spawnFfmpeg(["-filters"],{captureStdout:!0,stdoutLines:0},function(r,n){if(r)return e(r);var i=n.get(),a=i.split(` `),u={},l={A:"audio",V:"video","|":"none"};a.forEach(function(h){var p=h.match(A_);p&&(u[p[1]]={description:p[4],input:l[p[2].charAt(0)],multipleInputs:p[2].length>1,output:l[p[3].charAt(0)],multipleOutputs:p[3].length>1})}),e(null,le.filters=u)})},t.availableCodecs=t.getAvailableCodecs=function(e){if("codecs"in le)return e(null,le.codecs);this._spawnFfmpeg(["-codecs"],{captureStdout:!0,stdoutLines:0},function(r,n){if(r)return e(r);var i=n.get(),a=i.split(za),u={};a.forEach(function(l){var h=l.match(T_);if(h&&h[7]!=="="&&(u[h[7]]={type:{V:"video",A:"audio",S:"subtitle"}[h[3]],description:h[8],canDecode:h[1]==="D",canEncode:h[2]==="E",drawHorizBand:h[4]==="S",directRendering:h[5]==="D",weirdFrameTruncation:h[6]==="T"}),h=l.match(k_),h&&h[7]!=="="){var p=u[h[7]]={type:{V:"video",A:"audio",S:"subtitle"}[h[3]],description:h[8],canDecode:h[1]==="D",canEncode:h[2]==="E",intraFrameOnly:h[4]==="I",isLossy:h[5]==="L",isLossless:h[6]==="S"},m=p.description.match(D_);m=m?m[1].trim().split(" "):[];var y=p.description.match(P_);if(y=y?y[1].trim().split(" "):[],m.length||y.length){var v={};Wt.copy(p,v),delete v.canEncode,delete v.canDecode,m.forEach(function(b){u[b]={},Wt.copy(v,u[b]),u[b].canEncode=!0}),y.forEach(function(b){b in u||(u[b]={},Wt.copy(v,u[b])),u[b].canDecode=!0})}}}),e(null,le.codecs=u)})},t.availableEncoders=t.getAvailableEncoders=function(e){if("encoders"in le)return e(null,le.encoders);this._spawnFfmpeg(["-encoders"],{captureStdout:!0,stdoutLines:0},function(r,n){if(r)return e(r);var i=n.get(),a=i.split(za),u={};a.forEach(function(l){var h=l.match(F_);h&&h[7]!=="="&&(u[h[7]]={type:{V:"video",A:"audio",S:"subtitle"}[h[1]],description:h[8],frameMT:h[2]==="F",sliceMT:h[3]==="S",experimental:h[4]==="X",drawHorizBand:h[5]==="B",directRendering:h[6]==="D"})}),e(null,le.encoders=u)})},t.availableFormats=t.getAvailableFormats=function(e){if("formats"in le)return e(null,le.formats);this._spawnFfmpeg(["-formats"],{captureStdout:!0,stdoutLines:0},function(r,n){if(r)return e(r);var i=n.get(),a=i.split(za),u={};a.forEach(function(l){var h=l.match(R_);h&&h[3].split(",").forEach(function(p){p in u||(u[p]={description:h[4],canDemux:!1,canMux:!1}),h[1]==="D"&&(u[p].canDemux=!0),h[2]==="E"&&(u[p].canMux=!0)})}),e(null,le.formats=u)})},t._checkCapabilities=function(e){var r=this;Ai.waterfall([function(n){r.availableFormats(n)},function(n,i){var a;if(a=r._outputs.reduce(function(u,l){var h=l.options.find("-f",1);return h&&(!(h[0]in n)||!n[h[0]].canMux)&&u.push(h),u},[]),a.length===1)return i(new Error("Output format "+a[0]+" is not available"));if(a.length>1)return i(new Error("Output formats "+a.join(", ")+" are not available"));if(a=r._inputs.reduce(function(u,l){var h=l.options.find("-f",1);return h&&(!(h[0]in n)||!n[h[0]].canDemux)&&u.push(h[0]),u},[]),a.length===1)return i(new Error("Input format "+a[0]+" is not available"));if(a.length>1)return i(new Error("Input formats "+a.join(", ")+" are not available"));i()},function(n){r.availableEncoders(n)},function(n,i){var a;if(a=r._outputs.reduce(function(u,l){var h=l.audio.find("-acodec",1);return h&&h[0]!=="copy"&&(!(h[0]in n)||n[h[0]].type!=="audio")&&u.push(h[0]),u},[]),a.length===1)return i(new Error("Audio codec "+a[0]+" is not available"));if(a.length>1)return i(new Error("Audio codecs "+a.join(", ")+" are not available"));if(a=r._outputs.reduce(function(u,l){var h=l.video.find("-vcodec",1);return h&&h[0]!=="copy"&&(!(h[0]in n)||n[h[0]].type!=="video")&&u.push(h[0]),u},[]),a.length===1)return i(new Error("Video codec "+a[0]+" is not available"));if(a.length>1)return i(new Error("Video codecs "+a.join(", ")+" are not available"));i()}],e)}}});var df=k((fD,hf)=>{"use strict";var q_=require("child_process").spawn;function N_(t){return t.match(/^TAG:/)}function C_(t){return t.match(/^DISPOSITION:/)}function $_(t){var e=t.split(/\r\n|\r|\n/);e=e.filter(function(l){return l.length>0});var r={streams:[],format:{},chapters:[]};function n(l){for(var h={},p=e.shift();typeof p<"u";){if(p.toLowerCase()=="[/"+l+"]")return h;if(p.match(/^\[/)){p=e.shift();continue}var m=p.match(/^([^=]+)=(.*)$/);m&&(!m[1].match(/^TAG:/)&&m[2].match(/^[0-9]+(\.[0-9]+)?$/)?h[m[1]]=Number(m[2]):h[m[1]]=m[2]),p=e.shift()}return h}for(var i=e.shift();typeof i<"u";){if(i.match(/^\[stream/i)){var a=n("stream");r.streams.push(a)}else if(i.match(/^\[chapter/i)){var u=n("chapter");r.chapters.push(u)}else i.toLowerCase()==="[format]"&&(r.format=n("format"));i=e.shift()}return r}hf.exports=function(t){t.ffprobe=function(){var e,r=null,n=[],i,i=arguments[arguments.length-1],a=!1;function u(l,h){a||(a=!0,i(l,h))}switch(arguments.length){case 3:r=arguments[0],n=arguments[1];break;case 2:typeof arguments[0]=="number"?r=arguments[0]:Array.isArray(arguments[0])&&(n=arguments[0]);break}if(r===null){if(!this._currentInput)return u(new Error("No input specified"));e=this._currentInput}else if(e=this._inputs[r],!e)return u(new Error("Invalid input index"));this._getFfprobePath(function(l,h){if(l)return u(l);if(!h)return u(new Error("Cannot find ffprobe"));var p="",m=!1,y="",v=!1,b=e.isStream?"pipe:0":e.source,g=q_(h,["-show_streams","-show_format"].concat(n,b),{windowsHide:!0});e.isStream&&(g.stdin.on("error",function(j){["ECONNRESET","EPIPE","EOF"].indexOf(j.code)>=0||u(j)}),g.stdin.on("close",function(){e.source.pause(),e.source.unpipe(g.stdin)}),e.source.pipe(g.stdin)),g.on("error",i);var T=null;function D(j){if(j&&(T=j),N&&m&&v){if(T)return y&&(T.message+=` `+y),u(T);var F=$_(p);[F.format].concat(F.streams).forEach(function(L){if(L){var x=Object.keys(L).filter(N_);x.length&&(L.tags=L.tags||{},x.forEach(function(M){L.tags[M.substr(4)]=L[M],delete L[M]}));var _=Object.keys(L).filter(C_);_.length&&(L.disposition=L.disposition||{},_.forEach(function(M){L.disposition[M.substr(12)]=L[M],delete L[M]}))}}),u(null,F)}}var N=!1;g.on("exit",function(j,F){N=!0,j?D(new Error("ffprobe exited with code "+j)):F?D(new Error("ffprobe was killed with signal "+F)):D()}),g.stdout.on("data",function(j){p+=j}),g.stdout.on("close",function(){m=!0,D()}),g.stderr.on("data",function(j){y+=j}),g.stderr.on("close",function(){v=!0,D()})})}}});var yf=k((hD,gf)=>{"use strict";var pf=require("fs"),Ut=require("path"),I_=require("stream").PassThrough,L_=Ri(),mf=ft();gf.exports=function(e){e.saveToFile=e.save=function(r){return this.output(r).run(),this},e.writeToStream=e.pipe=e.stream=function(r,n){if(r&&!("writable"in r)&&(n=r,r=void 0),!r){if(process.version.match(/v0\.8\./))throw new Error("PassThrough stream is not supported on node v0.8");r=new I_}return this.output(r,n).run(),r},e.takeScreenshots=e.thumbnail=e.thumbnails=e.screenshot=e.screenshots=function(r,n){var i=this,a=this._currentInput.source;if(r=r||{count:1},typeof r=="number"&&(r={count:r}),"folder"in r||(r.folder=n||"."),"timestamps"in r&&(r.timemarks=r.timestamps),!("timemarks"in r)){if(!r.count)throw new Error("Cannot take screenshots: neither a count nor a timemark list are specified");var u=100/(1+r.count);r.timemarks=[];for(var l=0;l<r.count;l++)r.timemarks.push(u*(l+1)+"%")}if("size"in r){var h=r.size.match(/^(\d+)x(\d+)$/),p=r.size.match(/^(\d+)x\?$/),m=r.size.match(/^\?x(\d+)$/),y=r.size.match(/^(\d+)%$/);if(!h&&!p&&!m&&!y)throw new Error("Invalid size parameter: "+r.size)}var v;function b(g){v?g(null,v):i.ffprobe(function(T,D){v=D,g(T,D)})}return L_.waterfall([function(T){if(r.timemarks.some(function(D){return(""+D).match(/^[\d.]+%$/)})){if(typeof a!="string")return T(new Error("Cannot compute screenshot timemarks with an input stream, please specify fixed timemarks"));b(function(D,N){if(D)T(D);else{var j=N.streams.reduce(function(L,x){return x.codec_type==="video"&&x.width*x.height>L.width*L.height?x:L},{width:0,height:0});if(j.width===0)return T(new Error("No video stream in input, cannot take screenshots"));var F=Number(j.duration);if(isNaN(F)&&(F=Number(N.format.duration)),isNaN(F))return T(new Error("Could not get input duration, please specify fixed timemarks"));r.timemarks=r.timemarks.map(function(L){return(""+L).match(/^([\d.]+)%$/)?F*parseFloat(L)/100:L}),T()}})}else T()},function(T){r.timemarks=r.timemarks.map(function(D){return mf.timemarkToSeconds(D)}).sort(function(D,N){return D-N}),T()},function(T){var D=r.filename||"tn.png";if(D.indexOf(".")===-1&&(D+=".png"),r.timemarks.length>1&&!D.match(/%(s|0*i)/)){var N=Ut.extname(D);D=Ut.join(Ut.dirname(D),Ut.basename(D,N)+"_%i"+N)}T(null,D)},function(T,D){if(T.match(/%[bf]/)){if(typeof a!="string")return D(new Error("Cannot replace %f or %b when using an input stream"));T=T.replace(/%f/g,Ut.basename(a)).replace(/%b/g,Ut.basename(a,Ut.extname(a)))}D(null,T)},function(T,D){if(T.match(/%[whr]/)){if(h)return D(null,T,h[1],h[2]);b(function(N,j){if(N)return D(new Error("Could not determine video resolution to replace %w, %h or %r"));var F=j.streams.reduce(function(_,M){return M.codec_type==="video"&&M.width*M.height>_.width*_.height?M:_},{width:0,height:0});if(F.width===0)return D(new Error("No video stream in input, cannot replace %w, %h or %r"));var L=F.width,x=F.height;p?(x=x*Number(p[1])/L,L=Number(p[1])):m?(L=L*Number(m[1])/x,x=Number(m[1])):y&&(L=L*Number(y[1])/100,x=x*Number(y[1])/100),D(null,T,Math.round(L/2)*2,Math.round(x/2)*2)})}else D(null,T,-1,-1)},function(T,D,N,j){T=T.replace(/%r/g,"%wx%h").replace(/%w/g,D).replace(/%h/g,N),j(null,T)},function(T,D){var N=r.timemarks.map(function(j,F){return T.replace(/%s/g,mf.timemarkToSeconds(j)).replace(/%(0*)i/g,function(L,x){var _=""+(F+1);return x.substr(0,Math.max(0,x.length+1-_.length))+_})});i.emit("filenames",N),D(null,N)},function(T,D){pf.exists(r.folder,function(N){N?D(null,T):pf.mkdir(r.folder,function(j){j?D(j):D(null,T)})})}],function(T,D){if(T)return i.emit("error",T);var N=r.timemarks.length,j,F=[j={filter:"split",options:N,outputs:[]}];if("size"in r){i.size(r.size);var L=i._currentOutput.sizeFilters.get().map(function(O,w){return w>0&&(O.inputs="size"+(w-1)),O.outputs="size"+w,O});j.inputs="size"+(L.length-1),F=L.concat(F),i._currentOutput.sizeFilters.clear()}for(var x=0,_=0;_<N;_++){var M="screen"+_;j.outputs.push(M),_===0&&(x=r.timemarks[_],i.seekInput(x)),i.output(Ut.join(r.folder,D[_])).frames(1).map(M),_>0&&i.seek(r.timemarks[_]-x)}i.complexFilter(F),i.run()}),this},e.mergeToFile=e.concatenate=e.concat=function(r,n){var i=this._inputs.filter(function(u){return!u.isStream})[0],a=this;return this.ffprobe(this._inputs.indexOf(i),function(u,l){if(u)return a.emit("error",u);var h=l.streams.some(function(m){return m.codec_type==="audio"}),p=l.streams.some(function(m){return m.codec_type==="video"});a.output(r,n).complexFilter({filter:"concat",options:{n:a._inputs.length,v:p?1:0,a:h?1:0}}).run()}),this}}});var bf=k((dD,wf)=>{"use strict";var j_=require("path"),Y_=require("util"),vf=require("events").EventEmitter,Va=ft();function X(t,e){if(!(this instanceof X))return new X(t,e);vf.call(this),typeof t=="object"&&!("readable"in t)?e=t:(e=e||{},e.source=t),this._inputs=[],e.source&&this.input(e.source),this._outputs=[],this.output();var r=this;["_global","_complexFilters"].forEach(function(n){r[n]=Va.args()}),e.stdoutLin