PageSourceSearch

https://motioner.app/_app/immutable/chunks/B94t7Bx4.js

js motioner.app collected 2026-10-05 07:09:49 UTC 26,083 bytes, 12 lines download raw bytes

vendor: 4,793 bytes, line 1
1import{O as U,E as ue,Q as q,g as he,N as me,M as fe,V as Q,a as le,b as K,A as Y,c as pe,d as k,e as ie,B as Me}from"./BbWHrOC8.js";import{f as xe,h as Ve,i as Ne,C as ze,I as We,j as Le,k as je,l as Ge,m as Be,n as He,o as Ue,p as qe,P as Qe,q as Ke,R as Ye,S as $e,r as Xe,T as Je,s as Ze,t as Oe,u as et}from"./BbWHrOC8.js";import{I as we,v as $,p as re,a as ge,b as v,n as X,c as Te,d as P,E as J,V as Z,i as O,e as W,N as L,A as ee,t as _e,f as ye,g as be,h as Ce,j as te,k as ve,q as ae,u as ke,B as Re,w as Fe}from"./BM3LUJ3T.js";import{x as at,y as st,z as it,C as rt,D as ot,F as nt,G as dt,H as ct,J as ut,K as ht,L as mt,M as ft,O as lt,P as pt,Q as wt,R as gt,S as Tt,T as _t,U as yt,W as bt,X as Ct,Y as vt,Z as At,_ as St,$ as Et,a0 as Mt,a1 as Pt,a2 as kt,a3 as Rt,a4 as Ft,a5 as It,a6 as Dt,a7 as xt,a8 as Vt,a9 as Nt,aa as zt,ab as Wt,ac as Lt,ad as jt,ae as Gt,af as Bt,ag as Ht,ah as Ut,ai as qt,aj as Qt,ak as Kt,al as Yt,am as $t,an as Xt,ao as Jt}from"./BM3LUJ3T.js";const I=a=>{if(!a||typeof a!="object")throw new TypeError("options.video, when provided, must be an object.");if(a?.discard!==void 0&&typeof a.discard!="boolean")throw new TypeError("options.video.discard, when provided, must be a boolean.");if(a?.forceTranscode!==void 0&&typeof a.forceTranscode!="boolean")throw new TypeError("options.video.forceTranscode, when provided, must be a boolean.");if(a?.codec!==void 0&&!te.includes(a.codec))throw new TypeError(`options.video.codec, when provided, must be one of: ${te.join(", ")}.`);if(a?.bitrate!==void 0&&!(a.bitrate instanceof ie)&&(!Number.isInteger(a.bitrate)||a.bitrate<=0))throw new TypeError("options.video.bitrate, when provided, must be a positive integer or a quality.");if(a?.width!==void 0&&(!Number.isInteger(a.width)||a.width<=0))throw new TypeError("options.video.width, when provided, must be a positive integer.");if(a?.height!==void 0&&(!Number.isInteger(a.height)||a.height<=0))throw new TypeError("options.video.height, when provided, must be a positive integer.");if(a?.fit!==void 0&&!["fill","contain","cover"].includes(a.fit))throw new TypeError("options.video.fit, when provided, must be one of 'fill', 'contain', or 'cover'.");if(a?.width!==void 0&&a.height!==void 0&&a.fit===void 0)throw new TypeError("When both options.video.width and options.video.height are provided, options.video.fit must also be provided.");if(a?.rotate!==void 0&&![0,90,180,270].includes(a.rotate))throw new TypeError("options.video.rotate, when provided, must be 0, 90, 180 or 270.");if(a?.allowRotationMetadata!==void 0&&typeof a.allowRotationMetadata!="boolean")throw new TypeError("options.video.allowRotationMetadata, when provided, must be a boolean.");if(a?.crop!==void 0&&ve(a.crop,"options.video."),a?.frameRate!==void 0&&(!Number.isFinite(a.frameRate)||a.frameRate<=0))throw new TypeError("options.video.frameRate, when provided, must be a finite positive number.");if(a?.alpha!==void 0&&!["discard","keep"].includes(a.alpha))throw new TypeError("options.video.alpha, when provided, must be either 'discard' or 'keep'.");if(a?.keyFrameInterval!==void 0&&(!Number.isFinite(a.keyFrameInterval)||a.keyFrameInterval<0))throw new TypeError("options.video.keyFrameInterval, when provided, must be a non-negative number.");if(a?.process!==void 0&&typeof a.process!="function")throw new TypeError("options.video.process, when provided, must be a function.");if(a?.processedWidth!==void 0&&(!Number.isInteger(a.processedWidth)||a.processedWidth<=0))throw new TypeError("options.video.processedWidth, when provided, must be a positive integer.");if(a?.processedHeight!==void 0&&(!Number.isInteger(a.processedHeight)||a.processedHeight<=0))throw new TypeError("options.video.processedHeight, when provided, must be a positive integer.");if(a?.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(a.hardwareAcceleration))throw new TypeError("options.video.hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(a?.group!==void 0&&!(a.group instanceof k||Array.isArray(a.group)&&a.group.every(e=>e instanceof k)))throw new TypeError("options.video.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},D=a=>{if(!a||typeof a!="object")throw new TypeError("options.audio, when provided, must be an object.");if(a?.discard!==void 0&&typeof a.discard!="boolean")throw new TypeError("options.audio.discard, when provided, must be a boolean.");if(a?.forceTranscode!==void 0&&typeof a.forceTranscode!="boolean")throw new TypeError("options.audio.forceTranscode, when provided, must be a boolean.");if(a?.codec!==void 0&&!ae.includes(a.codec))throw new TypeError(`options.audio.codec, when provided, must be one of: ${ae.join(", ")}.`);
1if(a?.bitrate!==void 0&&!(a.bitrate instanceof ie)&&(!Number.isInteger(a.bitrate)||a.bitrate<=0))throw new TypeError("options.audio.bitrate, when provided, must be a positive integer or a quality.");if(a?.numberOfChannels!==void 0&&(!Number.isInteger(a.numberOfChannels)||a.numberOfChannels<=0))throw new TypeError("options.audio.numberOfChannels, when provided, must be a positive integer.");if(a?.sampleRate!==void 0&&(!Number.isInteger(a.sampleRate)||a.sampleRate<=0))throw new TypeError("options.audio.sampleRate, when provided, must be a positive integer.");if(a?.sampleFormat!==void 0&&!["u8","s16","s32","f32"].includes(a.sampleFormat))throw new TypeError("options.audio.sampleFormat, when provided, must be one of: u8, s16, s32, f32.");if(a?.process!==void 0&&typeof a.process!="function")throw new TypeError("options.audio.process, when provided, must be a function.");if(a?.processedNumberOfChannels!==void 0&&(!Number.isInteger(a.processedNumberOfChannels)||a.processedNumberOfChannels<=0))throw new TypeError("options.audio.processedNumberOfChannels, when provided, must be a positive integer.");if(a?.processedSampleRate!==void 0&&(!Number.isInteger(a.processedSampleRate)||a.processedSampleRate<=0))throw new TypeError("options.audio.processedSampleRate, when provided, must be a positive integer.");if(a?.group!==void 0&&!(a.group instanceof k||Array.isArray(a.group)&&a.group.every(e=>e instanceof k)))throw new TypeError("options.audio.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},j=2,G=48e3;class oe{static async init(e){const t=new oe(e);return await t._init(),t}constructor(e){if(this._addedCounts={video:0,audio:0,subtitle:0},this._totalTrackCount=0,this._nextOutputTrackId=0,this._outputTrackIds=[],this._outputOwnTrackGroups=[],this._trackPromises=[],this._executed=!1,this._synchronizer=new Se,this._totalDuration=null,this._maxTimestamps=new Map,this._canceled=!1,this.onProgress=void 0,this._computeProgress=!1,this._lastProgress=0,this.isValid=!1,this.utilizedTracks=[],this.discardedTracks=[],!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.input instanceof we))throw new TypeError("options.input must be an Input.");if(!(e.output instanceof U))throw new TypeError("options.output must be an Output.");if(e.tracks!==void 0&&e.tracks!=="all"&&e.tracks!=="primary")throw new TypeError("options.tracks, when provided, must be either 'all' or 'primary'.");if(e.output._tracks.length>0||Object.keys(e.output._metadataTags).length>0||e.output.state!=="pending")throw new TypeError("options.output must be fresh: no tracks or metadata tags added and not started.");if(e.video!==void 0&&typeof e.video!="function")if(Array.isArray(e.video))for(const s of e.video)I(s);else I(e.video);if(e.audio!==void 0&&typeof e.audio!="function")if(Array.isArray(e.audio))for(const s of e.audio)D(s);else D(e.audio);if(e.trim!==void 0&&(!e.trim||typeof e.trim!="object"))throw new TypeError("options.trim, when provided, must be an object.");if(e.trim?.start!==void 0&&!Number.isFinite(e.trim.start))throw new TypeError("options.trim.start, when provided, must be a finite number.");if(e.trim?.end!==void 0&&!Number.isFinite(e.trim.end))throw new TypeError("options.trim.end, when provided, must be a finite number.");if(e.trim?.start!==void 0&&e.trim.end!==void 0&&e.trim.start>=e.trim.end)throw new TypeError("options.trim.start must be less than options.trim.end.");if(e.tags!==void 0&&(typeof e.tags!="object"||!e.tags)&&typeof e.tags!="function")throw new TypeError("options.tags, when provided, must be an object or a function.");if(typeof e.tags=="object"&&$(e.tags),e.showWarnings!==void 0&&typeof e.showWarnings!="boolean")throw new TypeError("options.showWarnings, when provided, must be a boolean.");this._options=e,this.input=e.input,this.output=e.output;const{promise:t,resolve:i}=re();this._started=t,this._start=i}async _init(){const e=await this.input.getFormat();let t,i=this._options.tracks;if(i===void 0&&(i=e.name.includes("(HLS)")?"primary":"all"),i==="all")t=await this.input.getTracks();else if(i==="primary"){const d=await this.input.getPrimaryVideoTrack(),r=await this.input.getPrimaryAudioTrack();t=[d,r].filter(l=>l!==null)}else ge(i),v(!1);
1const s=this.output.format.getSupportedTrackCounts();let c=1,u=1;const n=[],T=[];for(const d of t){let r;if(d.isVideoTrack())if(this._options.video)if(typeof this._options.video=="function"){const o=await this._options.video(d,c)??{};if(Array.isArray(o))for(const h of o)I(h);else I(o);r=Array.isArray(o)?o:[o],c++}else r=Array.isArray(this._options.video)?this._options.video:[this._options.video];else r=[{}];else if(d.isAudioTrack())if(this._options.audio)if(typeof this._options.audio=="function"){const o=await this._options.audio(d,u)??{};if(Array.isArray(o))for(const h of o)D(h);else D(o);r=Array.isArray(o)?o:[o],u++}else r=Array.isArray(this._options.audio)?this._options.audio:[this._options.audio];else r=[{}];else v(!1);const l=r.filter(o=>o.discard);for(const o of l)this.discardedTracks.push({track:d,reason:"discarded_by_user",trackOptions:o});if(r.length===l.length){r.length===0&&this.discardedTracks.push({track:d,reason:"discarded_by_user",trackOptions:{}});continue}const f=r.filter(o=>!o.discard);n.push(d),T.push(f)}this._options.trim?.start!==void 0?this._startTimestamp=this._options.trim.start:this._startTimestamp=Math.max(await this.input.getFirstTimestamp(n),0),this._endTimestamp=Math.max(this._options.trim?.end??1/0,this._startTimestamp);for(let d=0;d<n.length;d++){const r=n[d],l=T[d];for(const f of l){if(this._totalTrackCount===s.total.max){this.discardedTracks.push({track:r,reason:"max_track_count_reached",trackOptions:f});continue}if(this._addedCounts[r.type]===s[r.type].max){this.discardedTracks.push({track:r,reason:"max_track_count_of_type_reached",trackOptions:f});continue}const o=this._nextOutputTrackId++;r.isVideoTrack()?await this._processVideoTrack(r,f,o):r.isAudioTrack()?await this._processAudioTrack(r,f,o):v(!1)}}for(let d=0;d<this.utilizedTracks.length-1;d++)for(let r=d+1;r<this.utilizedTracks.length;r++){const l=this.utilizedTracks[d],f=this.utilizedTracks[r],o=this._outputOwnTrackGroups[d],h=this._outputOwnTrackGroups[r];v(o!==void 0),v(h!==void 0),o&&h&&l.canBePairedWith(f)&&o.pairWith(h)}const w=await this.input.getMetadataTags();let g;if(this._options.tags){const d=typeof this._options.tags=="function"?await this._options.tags(w):this._options.tags;$(d),g=d}else g=w;const C=e.mimeType===this.output.format.mimeType,m=w.raw===g.raw;if(w.raw&&m&&!C&&delete g.raw,this.output.setMetadataTags(g),this.isValid=this._totalTrackCount>=s.total.min&&this._addedCounts.video>=s.video.min&&this._addedCounts.audio>=s.audio.min&&this._addedCounts.subtitle>=s.subtitle.min,this._options.showWarnings??!0){const d=[],r=this.discardedTracks.filter(l=>l.reason!=="discarded_by_user");r.length>0&&d.push("Some tracks had to be discarded from the conversion:",r),this.isValid||(d.length>0&&d.push(`
2
3`),d.push(this._getInvalidityExplanation().join(""))),d.length>0&&console.warn(...d)}}_getInvalidityExplanation(){const e=[];
3if(this.discardedTracks.length===0)e.push("Due to missing tracks, this conversion cannot be executed.");else{const t=this.discardedTracks.every(i=>i.reason==="discarded_by_user"||i.reason==="no_encodable_target_codec")&&this.discardedTracks.some(i=>i.reason==="no_encodable_target_codec");if(e.push("Due to discarded tracks, this conversion cannot be executed."),t){const i=this.discardedTracks.flatMap(c=>c.reason==="discarded_by_user"?[]:c.track.type==="video"?this.output.format.getSupportedVideoCodecs():c.track.type==="audio"?this.output.format.getSupportedAudioCodecs():this.output.format.getSupportedSubtitleCodecs()),s=[...new Set(i)];s.length===1?e.push(`
4Tracks were discarded because your environment is not able to encode '${s[0]}'.`):e.push(`
5Tracks were discarded because your environment is not able to encode any of the following codecs: ${s.map(c=>`'${c}'`).join(", ")}.`),s.includes("mp3")&&e.push(`
6The @mediabunny/mp3-encoder extension package provides support for encoding MP3.`),s.includes("aac")&&e.push(`
7The @mediabunny/aac-encoder extension package provides support for encoding AAC.`),(s.includes("ac3")||s.includes("eac3"))&&e.push(`
8The @mediabunny/ac3 extension package provides support for encoding and decoding AC-3/E-AC-3.`),s.includes("flac")&&e.push(`
9The @mediabunny/flac-encoder extension package provides support for encoding FLAC.`)}else e.push(`
10Check the discardedTracks field for more info.`)}return e}async execute(){if(!this.isValid)throw new Error(`Cannot execute this conversion because its output configuration is invalid. Make sure to always check the isValid field before executing a conversion.
11`+this._getInvalidityExplanation().join(""));if(this._executed)throw new Error("Conversion cannot be executed twice.");this._executed=!0;for(const e of this._outputTrackIds)this._synchronizer.declareTrack(e);if(this.onProgress){const t=[...new Set(this.utilizedTracks)].map(async s=>await s.isLive()?1/0:await s.getDurationFromMetadata()??await s.computeDuration()),i=Math.max(0,...await Promise.all(t));this._computeProgress=!0,this._totalDuration=Math.min(i-this._startTimestamp,this._endTimestamp-this._startTimestamp);for(const s of this._outputTrackIds)this._maxTimestamps.set(s,0);this.onProgress?.(0,0)}await this.output.start(),this._start();try{await Promise.all(this._trackPromises)}catch(e){throw this._canceled||this.cancel(),e}if(this._canceled)throw new Ae;if(await this.output.finalize(),this._computeProgress){const e=Math.min(...this._maxTimestamps.values());this.onProgress?.(1,e)}}async cancel(){if(!(this.output.state==="finalizing"||this.output.state==="finalized")){if(this._canceled){console.warn("Conversion already canceled.");return}this._canceled=!0,await this.output.cancel()}}async _processVideoTrack(e,t,i){const s=await e.getCodec();if(!s){this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});return}let c;const u=await e.getRotation(),n=X(u+(t.rotate??0));let T=n;const w=this.output.format.supportsVideoRotationMetadata&&(t.allowRotationMetadata??!0),g=await e.getSquarePixelWidth(),C=await e.getSquarePixelHeight(),[m,d]=n%180===0?[g,C]:[C,g];let r=t.crop;r&&(r=Te(r,m,d));const[l,f]=r?[r.width,r.height]:[m,d];let o=l,h=f;const p=o/h;t.width!==void 0&&t.height===void 0?(o=P(t.width),h=P(Math.round(o/p))):t.width===void 0&&t.height!==void 0?(h=P(t.height),o=P(Math.round(h*p))):t.width!==void 0&&t.height!==void 0&&(o=P(t.width),h=P(t.height));const _=await e.getFirstTimestamp();let y=this.output.format.getSupportedVideoCodecs();const de=!!t.forceTranscode||_<this._startTimestamp||!!t.frameRate||t.keyFrameInterval!==void 0||t.process!==void 0||t.bitrate!==void 0||!y.includes(s)||t.codec&&t.codec!==s||o!==l||h!==f||n!==0&&!w||!!r,x=t.alpha??"discard";if(de){if(!await e.canDecode()){this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});return}t.codec&&(y=y.filter(S=>S===t.codec));const F=t.bitrate??q,N=await he(y,{width:t.process&&t.processedWidth?t.processedWidth:o,height:t.process&&t.processedHeight?t.processedHeight:h,bitrate:F});if(!N){this.discardedTracks.push({track:e,reason:"no_encodable_target_co
11dec",trackOptions:t});return}const b={codec:N,bitrate:F,keyFrameInterval:t.keyFrameInterval,sizeChangeBehavior:t.fit??"passThrough",alpha:x,hardwareAcceleration:t.hardwareAcceleration,transform:{}};v(b.transform);let E=o!==l||h!==f||n!==0&&(!w||t.process!==void 0)||!!r||g!==await e.getCodedWidth()||C!==await e.getCodedHeight();if(!E){const S=new U({format:new fe,target:new me}),M=new Q(b);S.addVideoTrack(M),await S.start();const z=await new Z(e).getSample(_);if(z)try{await M.add(z),z.close(),await S.finalize()}catch(ce){console.info("Error when probing encoder support. Falling back to rerender path.",ce),E=!0,S.cancel()}else await S.cancel()}t.frameRate&&(b.transform.frameRate=t.frameRate),E&&(T=0,b.transform.width=o,b.transform.height=h,b.transform.fit=t.fit??"fill",b.transform.rotate=X(n-u),b.transform.crop=r,b.transform.alpha=x);const A=new Q(b);c=A,this._trackPromises.push((async()=>{await this._started;const S=new Z(e);for await(const M of S.samples(this._startTimestamp,this._endTimestamp)){if(this._canceled){M.close();return}const H=Math.max(M.timestamp-this._startTimestamp,0);M.setTimestamp(H),await this._registerVideoSample(t,i,A,M),M.close()}A.close(),this._synchronizer.closeTrack(i)})())}else{const R=new ue(s);c=R,this._trackPromises.push((async()=>{await this._started;const F=new J(e),b={decoderConfig:await e.getDecoderConfig()??void 0};for await(const E of F.packets(void 0,void 0,{verifyKeyPackets:!0})){if(this._canceled)return;if(E.timestamp>=this._endTimestamp)break;const A=E.clone({timestamp:E.timestamp-this._startTimestamp,sideData:x==="discard"?{}:E.sideData});v(A.timestamp>=0),this._reportProgress(i,A.timestamp+A.duration),await R.add(A,b),this._synchronizer.shouldWait(i,A.timestamp)&&await this._synchronizer.wait(A.timestamp)}R.close(),this._synchronizer.closeTrack(i)})())}let V=null;t.group||(V=new k);const B=await e.getLanguageCode();this.output.addVideoTrack(c,{frameRate:t.frameRate,languageCode:O(B)?B:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),rotation:T,group:V??t.group}),this._addedCounts.video++,this._totalTrackCount++,this.utilizedTracks.push(e),this._outputTrackIds.push(i),this._outputOwnTrackGroups.push(V)}async _registerVideoSample(e,t,i,s){if(this._canceled)return;this._reportProgress(t,s.timestamp+s.duration);let c;if(!e.process)c=[s];else{let u=e.process(s);u instanceof Promise&&(u=await u),Array.isArray(u)||(u=u===null?[]:[u]),c=u.map(n=>n instanceof W?n:typeof VideoFrame<"u"&&n instanceof VideoFrame?new W(n):new W(n,{timestamp:s.timestamp,duration:s.duration}))}try{for(const u of c){if(this._canceled)break;await i.add(u),this._synchronizer.shouldWait(t,u.timestamp)&&await this._synchronizer.wait(u.timestamp)}}finally{for(const u of c)u!==s&&u.close()}}async _processAudioTrack(e,t,i){const s=await e.getCodec();if(!s){this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});return}let c;const u=await e.getNumberOfChannels(),n=await e.getSampleRate(),T=await e.getFirstTimestamp();let w=t.numberOfChannels??u,g=t.sampleRate??n,C=w!==u||g!==n||T<this._startTimestamp||T>this._startTimestamp&&!this.output.format.supportsTimestampedMediaData,m=this.output.format.getSupportedAudioCodecs();if(!t.forceTranscode&&!t.bitrate&&!C&&m.includes(s)&&(!t.codec||t.codec===s)&&!t.process&&t.sampleFormat===void 0){const l=new le(s);c=l,this._trackPromises.push((async()=>{await this._started;const f=new J(e),h={decoderConfig:await e.getDecoderConfig()??void 0};for await(const p of f.packets()){if(this._canceled)return;if(p.timestamp>=this._endTimestamp)break;const _=p.clone({timestamp:p.timestamp-this._startTimestamp});v(_.timestamp>=0),this._reportProgress(i,_.timestamp+_.duration),await l.add(_,h),this._synchronizer.shouldWait(i,_.timestamp)&&await this._synchronizer.wait(_.timestamp)}l.close(),this._synchronizer.closeTrack(i)})())}else{if(!await e.canDecode()){this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});return}let f=null;t.codec&&(m=m.filter(p=>p===t.codec));const o=t.bitrate??q,h=await K(m,{numberOfChannels:t.process&&t.processedNumberOfChannels?t.processedNumberOfChannels:w,sampleRate:t.process&&t.processedSampleRate?t.processedSampleRate:g,bitrate:o});if(!h.some(p=>L.includes(p))&&m.some(p=>L.includes(p))&&(w!==j||g!==G)){const _=(await K(m,{numberOfChannels:j,sampleRate:G,bitrate:o})).find(y=>L.includes(y));_&&(C=!0,f=_,w=j,g=G)}else f=h[0]??null;if(f===null){this.discardedTracks.push({track:e,reason:"no_encodable_target_co
11dec",trackOptions:t});return}if(C)c=this._resampleAudio(e,t,i,f,w,g,o);else{const p=new Y({codec:f,bitrate:o});c=p,this._trackPromises.push((async()=>{await this._started;const _=new ee(e);for await(const y of _.samples(void 0,this._endTimestamp)){if(this._canceled){y.close();return}y.setTimestamp(y.timestamp-this._startTimestamp),await this._registerAudioSample(t,i,p,y),y.close()}p.close(),this._synchronizer.closeTrack(i)})())}}let d=null;t.group||(d=new k);const r=await e.getLanguageCode();this.output.addAudioTrack(c,{languageCode:O(r)?r:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),group:d??t.group}),this._addedCounts.audio++,this._totalTrackCount++,this.utilizedTracks.push(e),this._outputTrackIds.push(i),this._outputOwnTrackGroups.push(d)}async _registerAudioSample(e,t,i,s){if(this._canceled)return;let c=s;e.sampleFormat!==void 0&&_e(c.format)!==e.sampleFormat&&(c=ye(c,e.sampleFormat)),this._reportProgress(t,c.timestamp+c.duration);let u;if(!e.process)u=[c];else{let n=e.process(c);if(n instanceof Promise&&(n=await n),Array.isArray(n)||(n=n===null?[]:[n]),!n.every(T=>T instanceof be))throw new TypeError("The audio process function must return an AudioSample, null, or an array of AudioSamples.");u=n}try{for(const n of u){if(this._canceled)break;await i.add(n),this._synchronizer.shouldWait(t,n.timestamp)&&await this._synchronizer.wait(n.timestamp)}}finally{c!==s&&c.close();for(const n of u)n!==s&&n.close()}}_resampleAudio(e,t,i,s,c,u,n){const T=new Y({codec:s,bitrate:n});return this._trackPromises.push((async()=>{await this._started;const w=new pe({targetNumberOfChannels:c,targetSampleRate:u,startTime:this._startTimestamp,endTime:this._endTimestamp,onSample:async m=>{v(m.timestamp>=this._startTimestamp),m.setTimestamp(m.timestamp-this._startTimestamp),await this._registerAudioSample(t,i,T,m),m.close()}}),C=new ee(e).samples(this._startTimestamp,this._endTimestamp);for await(const m of C){if(this._canceled){m.close();return}await w.add(m),m.close()}await w.finalize(),T.close(),this._synchronizer.closeTrack(i)})()),T}_reportProgress(e,t){if(!this._computeProgress)return;v(this._totalDuration!==null),this._maxTimestamps.set(e,Math.max(t,this._maxTimestamps.get(e)));const i=Math.min(...this._maxTimestamps.values()),s=Ce(i/this._totalDuration,0,1);s!==this._lastProgress&&(this._lastProgress=s,this.onProgress?.(s,i))}}class Ae extends Error{constructor(e="Conversion has been canceled."){super(e),this.name="ConversionCanceledError"}}const se=1;class Se{constructor(){this.maxTimestamps=new Map,this.resolvers=[]}declareTrack(e){this.maxTimestamps.set(e,0)}shouldWait(e,t){const i=this.maxTimestamps.get(e);v(i!==void 0),this.maxTimestamps.set(e,Math.max(t,i));const s=this.computeMinAndMaybeResolve();return t-s>se}wait(e){const{promise:t,resolve:i}=re();return this.resolvers.push({timestamp:e,resolve:i}),t}closeTrack(e){this.maxTimestamps.delete(e),this.computeMinAndMaybeResolve()}computeMinAndMaybeResolve(){let e=1/0;for(const[,t]of this.maxTimestamps)e=Math.min(e,t);for(let t=0;t<this.resolvers.length;t++){const i=this.resolvers[t];i.timestamp-e<se&&(i.resolve(),this.resolvers.splice(t,1),t--)}return e}}const ne=Symbol.for("mediabunny loaded");globalThis[ne]&&console.error(`[WARNING]
12Mediabunny was loaded twice. This will likely cause Mediabunny not to work correctly. Check if multiple dependencies are importing different versions of Mediabunny, or if something is being bundled incorrectly.`);globalThis[ne]=!0;export{at as ADTS,ke as ALL_FORMATS,xe as ALL_TRACK_TYPES,ae as AUDIO_CODECS,st as AdtsInputFormat,it as AttachedFile,Fe as AudioBufferSink,Ve as AudioBufferSource,be as AudioSample,rt as AudioSampleResource,ee as AudioSampleSink,Y as AudioSampleSource,Ne as AudioSource,ot as BaseMediaSampleSink,Re as BlobSource,Me as BufferTarget,nt as CanvasSink,ze as CmafOutputFormat,oe as Conversion,Ae as ConversionCanceledError,dt as CustomPathedSource,le as EncodedAudioPacketSource,ct as EncodedPacket,J as EncodedPacketSink,ue as EncodedVideoPacketSource,ut as EventEmitter,ht as FLAC,mt as FlacInputFormat,ft as HLS,lt as HlsInputFormat,we as Input,pt as InputAudioTrack,wt as InputDisposedError,gt as InputFormat,Tt as InputTrack,_t as InputVideoTrack,yt as IsobmffInputFormat,We as IsobmffOutputFormat,bt as MATROSKA,Ct as MP3,vt as MP4,At as MPEG_TS,St as MatroskaInputFormat,Le as MediaSource,je as MovOutputFormat,Et as Mp3InputFormat,Mt as Mp4InputFormat,fe as Mp4OutputFormat,Pt as MpegTsInputFormat,L as NON_PCM_AUDIO_CODECS,me as NullTarget,kt as OGG,Rt as OggInputFormat,U as Output,Ge as OutputAudioTrack,Be as OutputFormat,He as OutputSubt
12itleTrack,Ue as OutputTrack,k as OutputTrackGroup,qe as OutputVideoTrack,Ft as PCM_AUDIO_CODECS,It as PathedSource,Qe as PathedTarget,Dt as QTFF,q as QUALITY_HIGH,Ke as QUALITY_MEDIUM,ie as Quality,xt as QuickTimeInputFormat,Vt as RangedSource,Ye as RangedTarget,Nt as ReadableStreamSource,zt as RichImageData,Wt as SUBTITLE_CODECS,Lt as Source,jt as SourceRef,$e as StreamTarget,Xe as SubtitleSource,Je as Target,Gt as UnsupportedInputFormatError,Bt as UrlSource,te as VIDEO_CODECS,Ht as VIDEO_SAMPLE_PIXEL_FORMATS,W as VideoSample,Ut as VideoSampleColorSpace,qt as VideoSampleResource,Z as VideoSampleSink,Q as VideoSampleSource,Ze as VideoSource,Qt as WAVE,Kt as WEBM,Yt as WaveInputFormat,$t as WebMInputFormat,Oe as canEncodeAudio,et as canEncodeVideo,Xt as desc,K as getEncodableAudioCodecs,he as getFirstEncodableVideoCodec,Jt as prefer};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.