(self.webpackChunkscreenity=self.webpackChunkscreenity||[]).push([[910],{5796(e,t,c){"use strict";c.r(t),c.d(t,{default:()=>r});var o=c(9136);const r=async function(e,t,c,r=()=>{}){return(new o.K_).convertToMP4(t,{videoBitrate:5e6,audioBitrate:128e3,onProgress:r})}},9136(e,t,c){"use strict";c.d(t,{K_:()=>p,Up:()=>h});var o=c(9917),r=c(7621),n=c(917),a=c(4709),d=c(5608),i=c(2030),s=c(1276);const u={avc:"H.264",hevc:"H.265 (HEVC)",vp9:"VP9",av1:"AV1",vp8:"VP8"};class p{constructor(){this.cachedMP4Codec=null,this.cachedWebMCodec=null}async convertToMP4(e,t={}){return this.convert(e,"mp4",t)}async convertToWebM(e,t={}){return this.convert(e,"webm",t)}async detectBestCodec(e){const t=("mp4"===e?new r.si({fastStart:!1}):new r.wQ).getSupportedVideoCodecs();for(const e of t)if(await this.canEncodeCodec(e))return{codec:e,displayName:u[e]||e.toUpperCase(),isPreferred:"avc"===e||"vp9"===e};return null}async canEncodeCodec(e){if("undefined"==typeof VideoEncoder)return!1;try{const t=this.getEncoderConfig(e);return(await VideoEncoder.isConfigSupported(t)).supported??!1}catch{return!1}}clearCache(){this.cachedMP4Codec=null,this.cachedWebMCodec=null}async convert(e,t,c){const{videoBitrate:u=5e6,audioBitrate:p=128e3,preferredVideoCodec:h,audioCodec:f,onProgress:w}=c;let v="mp4"===t?this.cachedMP4Codec:this.cachedWebMCodec;if(!v){if(h&&await this.canEncodeCodec(h))v=h;else{const e=await this.detectBestCodec(t);if(!e)throw new Error(`Cannot convert to ${t.toUpperCase()}: no supported video codec.`);v=e.codec}"mp4"===t?this.cachedMP4Codec=v:this.cachedWebMCodec=v}const C=f||("mp4"===t?"aac":"opus"),l=new i.pd({formats:d.XE,source:new a.Z7(e)}),b="mp4"===t?new r.si({fastStart:!1}):new r.wQ,m=c.target||new n.Sn,E=new o.k7({format:b,target:m}),g=await s.d.init({input:l,output:E,video:{codec:v,bitrate:u},audio:{codec:C,bitrate:p}});if(!g.isValid){const e=g.discardedTracks.map(e=>`${e.track.type}: ${e.reason}`).join(", ");throw new Error(`Conversion failed - ${e}`)}if(w&&(g.onProgress=w),await g.execute(),c.target)return null;if(!m.buffer)throw new Error("Conversion failed - no output buffer");return new Blob([m.buffer],{type:"mp4"===t?"video/mp4":"video/webm"})}getEncoderConfig(e){const t={width:1920,height:1080,bitrate:5e6};switch(e){case"avc":return{...t,codec:"avc1.42E01E"};case"hevc":return{...t,codec:"hev1.1.6.L93.B0"};default:return{...t,codec:e}}}}const h=new p},1845(){}}]);