@lumen5/framefusion 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/framefusion.cjs +1 -1
- package/dist/framefusion.cjs.map +1 -1
- package/dist/framefusion.es.js +129 -129
- package/dist/framefusion.es.js.map +1 -1
- package/dist/src/backends/beamcoder.js +4 -1
- package/dist/src/backends/beamcoder.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -69,10 +69,10 @@ For a complete working project (with package.json, vite config, typescript confi
|
|
|
69
69
|
|
|
70
70
|
# Running test
|
|
71
71
|
|
|
72
|
-
Make sure you run node
|
|
72
|
+
Make sure you run node 24 or higher.
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
nvm use
|
|
75
|
+
nvm use 24
|
|
76
76
|
yarn install && yarn run test-ui
|
|
77
77
|
```
|
|
78
78
|
|
package/dist/framefusion.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var B=(a,
|
|
1
|
+
"use strict";var B=(a,i,t)=>{if(!i.has(a))throw TypeError("Cannot "+t)};var e=(a,i,t)=>(B(a,i,"read from private field"),t?t.call(a):i.get(a)),d=(a,i,t)=>{if(i.has(a))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(a):i.set(a,t)},o=(a,i,t,s)=>(B(a,i,"write to private field"),s?s.call(a,t):i.set(a,t),t),F=(a,i,t,s)=>({set _(r){o(a,i,r,t)},get _(){return e(a,i,s)}}),V=(a,i,t)=>(B(a,i,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("@lumen5/beamcoder"),O=require("path"),j=require("tmp"),z=require("fs-extra");class H{static async create(i){throw new Error("Not implemented")}async init({inputFileOrUrl:i,outputFile:t,threadCount:s=8,endTime:r,interpolateFps:h,interpolateMode:l}){throw new Error("Not implemented")}get duration(){throw new Error("Not implemented")}get width(){throw new Error("Not implemented")}get height(){throw new Error("Not implemented")}async seekToPTS(i){throw new Error("Not implemented")}async getFrameAtTime(i){throw new Error("Not implemented")}async getImageDataAtTime(i){throw new Error("Not implemented")}async getFrameAtPts(i){throw new Error("Not implemented")}async seekToTime(i){throw new Error("Not implemented")}ptsToTime(i){throw new Error("Not implemented")}async readFrames({onFrameAvailable:i,flush:t=!0}={flush:!0,onFrameAvailable:()=>!0}){throw new Error("Not implemented")}async dispose(){throw new Error("Not implemented")}}var A,R,x,E;class W{constructor(i){d(this,A,void 0);d(this,R,void 0);d(this,x,void 0);d(this,E,void 0);o(this,A,i);const t=O.extname(i);o(this,E,j.fileSync({postfix:t})),o(this,x,e(this,E).name)}get filepath(){return e(this,x)}async download(){const i=e(this,A),t=await fetch(i);if(!t.ok)throw new Error(`Failed to fetch ${i}, status: ${t.status}`);const s=t.headers.get("content-type");if(!s||!s.includes("video"))throw new Error(`Source ${i}, returned unsupported content type ${s}`);const r=z.createWriteStream(e(this,E).name),h=t.body;if(!h)throw new Error(`Response body is null for ${i}`);const l=h.getReader();return new Promise((w,n)=>{const m=()=>{l.read().then(({done:f,value:_})=>{if(f){r.end(()=>{o(this,x,e(this,E).name),w()});return}const $=Buffer.from(_);r.write($)?m():r.once("drain",m)}).catch(n)};r.on("error",n),m()})}clear(){e(this,E)&&e(this,E).removeCallback(),e(this,A)&&o(this,A,void 0),e(this,R)&&o(this,R,null),e(this,x)&&o(this,x,void 0)}}A=new WeakMap,R=new WeakMap,x=new WeakMap,E=new WeakMap;const L=4,X=({demuxer:a,streamIndex:i,threadCount:t})=>{const s={width:a.streams[i].codecpar.width,height:a.streams[i].codecpar.height,pix_fmt:a.streams[i].codecpar.format,thread_count:t};return a.streams[i].codecpar.name==="vp8"?D.decoder({...s,name:"libvpx"}):a.streams[i].codecpar.name==="vp9"?D.decoder({...s,name:"libvpx-vp9"}):D.decoder({...s,demuxer:a,stream_index:i})},Y=async({stream:a,outputPixelFormat:i,interpolateFps:t,interpolateMode:s="fast"})=>{if(!a.codecpar.format)return null;let r=[`[in0:v]format=${a.codecpar.format}`];if(t)if(s==="high-quality")r=[...r,`minterpolate=fps=${t}`];else if(s==="fast")r=[...r,`fps=${t}`];else throw new Error(`Unexpected interpolation mode: ${s}`);const h=r.join(", ")+"[out0:v]";return D.filterer({filterType:"video",inputParams:[{name:"in0:v",width:a.codecpar.width,height:a.codecpar.height,pixelFormat:a.codecpar.format,timeBase:a.time_base,pixelAspect:a.sample_aspect_ratio}],outputParams:[{name:"out0:v",pixelFormat:i}],filterSpec:h})},q="video",K="audio",Z=5;var c,u,N,g,y,T,v,S,p,b,k,C,G;const M=class extends H{constructor(){super(...arguments);d(this,C);d(this,c,null);d(this,u,null);d(this,N,null);d(this,g,[]);d(this,y,[]);d(this,T,null);d(this,v,null);d(this,S,8);d(this,p,0);d(this,b,0);d(this,k,0)}static async create(t){const s=new M;return await s.init(t),s}async init({inputFileOrUrl:t,threadCount:s=8,outputPixelFormat:r="rgba"}){if(o(this,S,s),t.startsWith("http")){const n=new W(t);await n.download(),t=n.filepath}if(t.startsWith("file:")||(t="file:"+t),o(this,c,await D.demuxer(t)),o(this,p,e(this,c).streams.findIndex(n=>n.codecpar.codec_type===q)),e(this,p)===-1)throw new Error(`File has no ${q} stream!`);let h="rgba";const l=e(this,c).streams[e(this,p)].codecpar.format,w=e(this,c).streams[e(this,p)].codecpar.name;r==="original"&&w!=="vp8"&&w!=="vp9"&&(h=l),o(this,N,await Y({stream:e(this,c).streams[e(this,p)],outputPixelFormat:h}))}get duration(){return Math.max(...e(this,c).streams.filter(s=>s.codecpar.codec_type===q||s.codecpar.codec_type===K).map(s=>{const r=s.time_base;return s.duration*r[0]/r[1]}))||this.ptsToTime(e(this,c).duration)/1e3}get width(){return e(this,c).streams[e(this,p)].codecpar.width}get height(){return e(this,c).streams[e(this,p)].codecpar.height}async getFrameAtTime(t){const s=Math.round(this._timeToPTS(t));return this._getFrameAtPts(s)}async getImageDataAtTime(t,s){const r=Math.round(this._timeToPTS(t)),h=await this._getFrameAtPts(r);return h?(s&&M._setFrameDataToRGBABufferTarget(h,s),{width:h.width,height:h.height,frame:h}):null}_timeToPTS(t){const s=e(this,c).streams[e(this,p)].time_base;return t*s[1]/s[0]}ptsToTime(t){const s=e(this,c).streams[e(this,p)].time_base;return t*s[0]/s[1]}get packetReadCount(){return e(this,b)}async _getFrameAtPts(t,s=0){o(this,b,0);const r=3,h=e(this,g).flat().some(m=>this.ptsToTime(Math.abs(t-m.pts))<r);(e(this,v)===null||e(this,v)>t||!h)&&(await e(this,c).seek({stream_index:0,timestamp:t+s,any:!1}),await V(this,C,G).call(this),o(this,T,null),o(this,y,[]),o(this,v,t),o(this,g,[]));let l=null,w=-1,n=null;if(e(this,g).length>0){const m=e(this,g).flat().find(f=>f.pts<=t);if(m){const f=e(this,g).flat().find(_=>_.pts>m.pts);if(w=m.pts,n=m,f&&f.pts>t||w===t)return o(this,v,t),n}}for(!e(this,T)&&e(this,y).length===0&&({packet:F(this,T)._,frames:F(this,y)._}=await this._getNextPacketAndDecodeFrames(),F(this,b)._++);(e(this,T)||e(this,y).length!==0)&&w<t;){if(e(this,y).length!==0){l=(await e(this,N).filter([{name:"in0:v",frames:e(this,y)}])).flatMap(_=>_.frames);const f=e(this,b)===1&&l[0].pts>t?l[0]:l.reverse().find(_=>_.pts<=t);if(!f)return n;if(e(this,g).unshift(l),e(this,g).length>2&&e(this,g).pop(),w=f==null?void 0:f.pts,!n||w<=t)o(this,v,t),n=f;else break}({packet:F(this,T)._,frames:F(this,y)._}=await this._getNextPacketAndDecodeFrames()),F(this,b)._++}if(!n){if(Z<e(this,k))throw Error("No matching frame found");const m=.1,f=this._timeToPTS(m);F(this,k)._++,n=await this._getFrameAtPts(t,s-f),n&&o(this,k,0)}return n}async _getNextPacketAndDecodeFrames(){const t=await this._getNextVideoStreamPacket();let s=null;t!==null&&e(this,u)?s=await e(this,u).decode(t):e(this,u)&&(s=await e(this,u).flush(),o(this,u,null));let r=[];return s&&s.frames.length!==0&&(r=s.frames),{packet:t,frames:r}}async _getNextVideoStreamPacket(){let t=await e(this,c).read();for(;t&&t.stream_index!==e(this,p);)if(t=await e(this,c).read(),t===null)return null;return t}static _setFrameDataToRGBABufferTarget(t,s){const r=t.linesize,h=t.data[0],l=t.width,w=t.height;for(let n=0;n<w;n++){const m=n*r,f=m+l*L,_=h.subarray(m,f),$=n*l*L;s.set(_,$)}}async dispose(){e(this,u)&&(await e(this,u).flush(),o(this,u,null)),e(this,c).forceClose(),o(this,N,null),o(this,g,void 0),o(this,y,[]),o(this,T,null),o(this,v,null),o(this,p,0)}};let I=M;c=new WeakMap,u=new WeakMap,N=new WeakMap,g=new WeakMap,y=new WeakMap,T=new WeakMap,v=new WeakMap,S=new WeakMap,p=new WeakMap,b=new WeakMap,k=new WeakMap,C=new WeakSet,G=async function(){e(this,u)&&(await e(this,u).flush(),o(this,u,null)),o(this,u,X({demuxer:e(this,c),streamIndex:e(this,p),threadCount:e(this,S)}))};var P;class J{constructor(){d(this,P,new Map)}get(i){const t=this;let s;return{url:i,get filepath(){return s},async download(){let r=e(t,P).get(i);if(r)r.refCount+=1,r.downloadPromise&&await r.downloadPromise;else{const h=new W(i),l=h.download();r={downloader:h,refCount:1,downloadPromise:l},e(t,P).set(i,r);try{await l}finally{r.downloadPromise=void 0}}s=e(t,P).get(i).downloader.filepath},destroy(){const r=e(t,P).get(i);r&&(r.refCount-=1,r.refCount<=0&&(r.downloader.clear(),e(t,P).delete(i)),s=void 0)}}}}P=new WeakMap;exports.BeamcoderExtractor=I;exports.CachedVideoDownloader=J;
|
|
2
2
|
//# sourceMappingURL=framefusion.cjs.map
|
package/dist/framefusion.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framefusion.cjs","sources":["../src/BaseExtractor.ts","../src/DownloadVideoURL.ts","../src/backends/beamcoder.ts","../src/cachedVideoDownloader.ts"],"sourcesContent":["import type {\n ExtractorArgs,\n Frame,\n Extractor\n} from '../framefusion';\nimport type { ImageData } from './types';\n\n\nexport class BaseExtractor implements Extractor {\n static async create(args: ExtractorArgs): Promise<Extractor> {\n throw new Error('Not implemented');\n }\n\n async init({\n inputFileOrUrl,\n outputFile,\n threadCount = 8,\n endTime,\n interpolateFps,\n interpolateMode,\n }: ExtractorArgs): Promise<void> {\n throw new Error('Not implemented');\n }\n\n get duration(): number {\n throw new Error('Not implemented');\n }\n\n get width(): number {\n throw new Error('Not implemented');\n }\n\n get height(): number {\n throw new Error('Not implemented');\n }\n\n async seekToPTS(targetPts: number) {\n throw new Error('Not implemented');\n }\n\n async getFrameAtTime(targetTime: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async getImageDataAtTime(targetTime: number): Promise<ImageData> {\n throw new Error('Not implemented');\n }\n\n async getFrameAtPts(targetPts: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async seekToTime(targetTime: number) {\n throw new Error('Not implemented');\n }\n\n /**\n * Convert a PTS (based on timebase) to PTS (in seconds)\n */\n ptsToTime(pts: number) {\n throw new Error('Not implemented');\n }\n\n async readFrames({\n onFrameAvailable,\n flush = true,\n }: {\n /**\n * Return true if we need to read more frames.\n */\n onFrameAvailable?: (frame: Frame) => Promise<boolean> | boolean;\n flush?: boolean;\n } = {\n flush: true,\n onFrameAvailable: () => true,\n }) {\n throw new Error('Not implemented');\n }\n\n async dispose() {\n throw new Error('Not implemented');\n }\n}\n","import path from 'path';\nimport type { ClientRequest } from 'http';\nimport tmp from 'tmp';\nimport fs from 'fs-extra';\n\n/**\n * Downloads a video file from a given URL as a temporary file. When the object is cleared, the temporary file is\n * deleted.\n */\nexport class DownloadVideoURL {\n #url: string | undefined;\n #httpRequest: ClientRequest | undefined = undefined;\n #filepath: string;\n #tmpObj: tmp.FileResult | undefined = undefined;\n\n constructor(url: string) {\n this.#url = url;\n\n const extension = path.extname(url);\n this.#tmpObj = tmp.fileSync({ postfix: extension });\n this.#filepath = this.#tmpObj.name;\n }\n\n /**\n * returns the filepath of the downloaded file. If the file has not been downloaded yet, it will be undefined\n */\n get filepath() {\n return this.#filepath;\n }\n\n /**\n * Downloads the file from the given URL. The file will be downloaded to a temporary file.\n */\n async download() {\n const source = this.#url;\n\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch ${source}, status: ${response.status}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n if (!contentType || !contentType.includes('video')) {\n throw new Error(\n `Source ${source}, returned unsupported content type ${contentType}`\n );\n }\n\n const writeStream = fs.createWriteStream(this.#tmpObj.name);\n const readableStream = response.body;\n\n if (!readableStream) {\n throw new Error(`Response body is null for ${source}`);\n }\n\n const reader = readableStream.getReader();\n\n return new Promise<void>((resolve, reject) => {\n const pump = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n writeStream.end(() => {\n this.#filepath = this.#tmpObj.name;\n resolve();\n });\n return;\n }\n const buffer = Buffer.from(value);\n if (!writeStream.write(buffer)) {\n // Wait for 'drain' before continuing\n writeStream.once('drain', pump);\n }\n else {\n pump();\n }\n }).catch(reject);\n };\n\n writeStream.on('error', reject);\n pump();\n });\n }\n\n clear() {\n if (this.#tmpObj) this.#tmpObj.removeCallback();\n if (this.#url) this.#url = undefined;\n if (this.#httpRequest) this.#httpRequest = null;\n if (this.#filepath) this.#filepath = undefined;\n }\n}\n","import type {\n Packet,\n Demuxer,\n Decoder,\n Filterer,\n Frame\n} from '@lumen5/beamcoder';\nimport beamcoder from '@lumen5/beamcoder';\nimport type { ImageData } from '../types';\nimport { BaseExtractor } from '../BaseExtractor';\nimport type { Extractor, ExtractorArgs, InterpolateMode } from '../../framefusion';\nimport { DownloadVideoURL } from '../DownloadVideoURL';\n\nconst VERBOSE = false;\n\n/**\n * RGBA format need one byte for every components: r, g, b and a\n */\nexport const RGBA_PIXEL_SIZE = 4;\n\nconst createDecoder = ({\n demuxer,\n streamIndex,\n threadCount,\n}: {\n demuxer: Demuxer;\n streamIndex: number;\n threadCount: number;\n}): Decoder => {\n const commonParams = {\n width: demuxer.streams[streamIndex].codecpar.width,\n height: demuxer.streams[streamIndex].codecpar.height,\n pix_fmt: demuxer.streams[streamIndex].codecpar.format,\n thread_count: threadCount,\n };\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp8') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx',\n });\n }\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp9') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx-vp9',\n });\n }\n\n return beamcoder.decoder({\n ...commonParams,\n demuxer: demuxer,\n stream_index: streamIndex,\n });\n};\n\n/**\n * A filter to convert between color spaces.\n * An example would be YUV to RGB, for mp4 to png conversion.\n */\nconst createFilter = async({\n stream,\n outputPixelFormat,\n interpolateFps,\n interpolateMode = 'fast',\n}: {\n stream: beamcoder.Stream;\n outputPixelFormat: string;\n interpolateFps?: number;\n interpolateMode?: InterpolateMode;\n}): Promise<beamcoder.Filterer> => {\n if (!stream.codecpar.format) {\n return null;\n }\n\n let filterSpec = [`[in0:v]format=${stream.codecpar.format}`];\n\n if (interpolateFps) {\n if (interpolateMode === 'high-quality') {\n filterSpec = [...filterSpec, `minterpolate=fps=${interpolateFps}`];\n }\n else if (interpolateMode === 'fast') {\n filterSpec = [...filterSpec, `fps=${interpolateFps}`];\n }\n else {\n throw new Error(`Unexpected interpolation mode: ${interpolateMode}`);\n }\n }\n\n const filterSpecStr = filterSpec.join(', ') + '[out0:v]';\n\n VERBOSE && console.log(`filterSpec: ${filterSpecStr}`);\n\n return beamcoder.filterer({\n filterType: 'video',\n inputParams: [\n {\n name: 'in0:v',\n width: stream.codecpar.width,\n height: stream.codecpar.height,\n pixelFormat: stream.codecpar.format,\n timeBase: stream.time_base,\n pixelAspect: stream.sample_aspect_ratio,\n },\n ],\n outputParams: [\n {\n name: 'out0:v',\n pixelFormat: outputPixelFormat,\n },\n ],\n filterSpec: filterSpecStr,\n });\n};\n\nconst STREAM_TYPE_VIDEO = 'video';\nconst MAX_RECURSION = 5;\n\n/**\n * A simple extractor that uses beamcoder to extract frames from a video file.\n */\nexport class BeamcoderExtractor extends BaseExtractor implements Extractor {\n /**\n * The demuxer reads the file and outputs packet streams\n */\n #demuxer: Demuxer = null;\n\n /**\n * The decoder reads packets and can output raw frame data\n */\n #decoder: Decoder = null;\n\n /**\n * Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or\n * filters, filter might not be necessary.\n */\n #filterer: Filterer = null;\n\n /**\n * This is where we store filtered frames from each previously processed packet.\n * We keep these in chronological order. We hang on to them for two reasons:\n * 1. so we can return them if we get a request for the same time again\n * 2. so we can return frames close the end of the stream. When such a frame is requested we have to flush (destroy)\n * the encoder to get the last few frames. This avoids having to re-create an encoder.\n */\n #filteredFramesPacket: undefined[] | Array<Array<Frame>> = [];\n\n /**\n * This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We\n * do this ensure we don't skip any frames.\n */\n #frames = [];\n\n /**\n * This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do\n * this ensure we don't skip any frames.\n */\n #packet: null | Packet = null;\n\n /**\n * The last target presentation timestamp (PTS) we requested. If we never requested a time(stamp) then this\n * value is null\n */\n #previousTargetPTS: null | number = null;\n\n /**\n * The number of threads to use for decoding\n */\n #threadCount = 8;\n\n /**\n * The index of the video stream in the demuxer\n */\n #streamIndex = 0;\n\n /**\n * The number of packets we've read from the demuxer to complete the frame query\n * @private\n */\n #packetReadCount = 0;\n\n /**\n * The number of times we've recursively read packets from the demuxer to complete the frame query\n * @private\n */\n #recursiveReadCount = 0;\n\n /**\n * Encoder/Decoder construction is async, so it can't be put in a regular constructor.\n * Use and await this method to generate an extractor.\n */\n static async create(args: ExtractorArgs): Promise<BeamcoderExtractor> {\n const extractor = new BeamcoderExtractor();\n await extractor.init(args);\n return extractor;\n }\n\n async init({\n inputFileOrUrl,\n threadCount = 8,\n outputPixelFormat = 'rgba',\n }: ExtractorArgs): Promise<void> {\n this.#threadCount = threadCount;\n VERBOSE && console.log('inputFileOrUrl before pre-processing: ', inputFileOrUrl);\n if (inputFileOrUrl.startsWith('http')) {\n VERBOSE && console.log('downloading url', inputFileOrUrl);\n const downloadUrl = new DownloadVideoURL(inputFileOrUrl);\n await downloadUrl.download();\n inputFileOrUrl = downloadUrl.filepath;\n VERBOSE && console.log('finished downloading');\n }\n // Assume file url at this point\n if (!inputFileOrUrl.startsWith('file:')) {\n inputFileOrUrl = 'file:' + inputFileOrUrl;\n }\n VERBOSE && console.log('inputFileOrUrl after pre-processing: ', inputFileOrUrl);\n VERBOSE && console.log('beamcoder.protocols(): ', JSON.stringify(beamcoder.protocols()));\n this.#demuxer = await beamcoder.demuxer(inputFileOrUrl);\n VERBOSE && console.log('demuxer creation succeeded.');\n this.#streamIndex = this.#demuxer.streams.findIndex(stream => stream.codecpar.codec_type === STREAM_TYPE_VIDEO);\n\n if (this.#streamIndex === -1) {\n throw new Error(`File has no ${STREAM_TYPE_VIDEO} stream!`);\n }\n let pixelFormat = 'rgba';\n const origianlPixelFormat = this.#demuxer.streams[this.#streamIndex].codecpar.format;\n const codecName = this.#demuxer.streams[this.#streamIndex].codecpar.name;\n // vp8 and vp9 this.#demuxer.streams[this.#streamIndex].codecpar.format is 'yuv420p', but the decoder outputs yuva420p\n if (outputPixelFormat === 'original' && codecName !== 'vp8' && codecName !== 'vp9') {\n pixelFormat = origianlPixelFormat;\n }\n this.#filterer = await createFilter({\n stream: this.#demuxer.streams[this.#streamIndex],\n outputPixelFormat: pixelFormat,\n });\n }\n\n async #createDecoder() {\n // It's possible that we need to create decoder multiple times during the lifecycle of this extractor so we\n // need to make sure we destroy the old one first if it exists\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#decoder = createDecoder({\n demuxer: this.#demuxer as Demuxer,\n streamIndex: this.#streamIndex,\n threadCount: this.#threadCount,\n });\n }\n\n get duration(): number {\n const maxStreamsDuration = Math.max(...this.#demuxer.streams\n .map(s => {\n const time_base = s.time_base;\n return s.duration * time_base[0] / time_base[1];\n }));\n // MP4 duration is defined as the longest stream duration\n // Webm stores it in Segment.Info.Duration\n return maxStreamsDuration || (this.ptsToTime(this.#demuxer.duration) / 1000);\n }\n\n /**\n * Width in pixels\n */\n get width(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.width;\n }\n\n /**\n * Height in pixels\n */\n get height(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.height;\n }\n\n /**\n * Get the beamcoder Frame for a given time in seconds\n * @param targetTime\n */\n async getFrameAtTime(targetTime: number): Promise<beamcoder.Frame> {\n VERBOSE && console.log(`getFrameAtTime time(s)=${targetTime}`);\n const targetPts = Math.round(this._timeToPTS(targetTime));\n return this._getFrameAtPts(targetPts);\n }\n\n /**\n * Get imageData for a given time in seconds\n * @param targetTime\n */\n async getImageDataAtTime(targetTime: number, rgbaBufferTarget?: Uint8ClampedArray): Promise<ImageData> {\n const targetPts = Math.round(this._timeToPTS(targetTime));\n VERBOSE && console.log('targetTime', targetTime, '-> targetPts', targetPts);\n const frame = await this._getFrameAtPts(targetPts);\n if (!frame) {\n VERBOSE && console.log('no frame found');\n return null;\n }\n\n if (rgbaBufferTarget) {\n BeamcoderExtractor._setFrameDataToRGBABufferTarget(frame, rgbaBufferTarget);\n }\n\n return {\n width: frame.width,\n height: frame.height,\n frame,\n };\n }\n\n /**\n * Get the presentation timestamp (PTS) for a given time in seconds\n */\n _timeToPTS(time: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return time * time_base[1] / time_base[0];\n }\n\n /**\n * Get the time in seconds from a given presentation timestamp (PTS)\n */\n ptsToTime(pts: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return pts * time_base[0] / time_base[1];\n }\n\n get packetReadCount() {\n return this.#packetReadCount;\n }\n\n /**\n * Get the frame at the given presentation timestamp (PTS)\n * @param targetPTS - the target presentation timestamp (PTS) we want to retrieve\n * @param SeekPTSOffset - the offset to use when seeking to the targetPTS. This is used when we have trouble finding\n * the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read\n * additional packets and find a frame that is closer to the targetPTS.\n */\n async _getFrameAtPts(targetPTS: number, SeekPTSOffset = 0): Promise<beamcoder.Frame> {\n VERBOSE && console.log('_getFrameAtPts', targetPTS, 'seekPTSOffset', SeekPTSOffset, 'duration', this.duration);\n this.#packetReadCount = 0;\n\n // seek and create a decoder when retrieving a frame for the first time or when seeking backwards\n // we have to create a new decoder when seeking backwards as the decoder can only process frames in\n // chronological order.\n // RE_SEEK_DELTA: sometimes, we are looking for a frame so far ahead that it's better to drop everything and seek.\n // Example: when we got a frame a 0 and request a frame at t = 30s just after, we don't want to start reading all packets\n // until 30s.\n const RE_SEEK_THRESHOLD = 3; // 3 seconds - typically we have keyframes at shorter intervals\n const hasFrameWithinThreshold = this.#filteredFramesPacket.flat().some(frame => {\n return this.ptsToTime(Math.abs(targetPTS - (frame as Frame).pts)) < RE_SEEK_THRESHOLD;\n });\n VERBOSE && console.log('hasPreviousTargetPTS:', this.#previousTargetPTS === null, ', targetPTS is smaller:', this.#previousTargetPTS > targetPTS, ', has frame within threshold:', hasFrameWithinThreshold);\n if (this.#previousTargetPTS === null || this.#previousTargetPTS > targetPTS || !hasFrameWithinThreshold) {\n VERBOSE && console.log(`Seeking to ${targetPTS + SeekPTSOffset}`);\n\n await this.#demuxer.seek({\n stream_index: 0, // even though we specify the stream index, it still seeks all streams\n timestamp: targetPTS + SeekPTSOffset,\n any: false,\n });\n await this.#createDecoder();\n this.#packet = null;\n this.#frames = [];\n this.#previousTargetPTS = targetPTS;\n this.#filteredFramesPacket = [];\n }\n\n let filteredFrames = null;\n let closestFramePTS = -1;\n let outputFrame = null;\n\n // If we have previously filtered frames, get the frame closest to our targetPTS\n if (this.#filteredFramesPacket.length > 0) {\n const closestFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts <= targetPTS) as Frame;\n\n if (closestFrame) {\n const nextFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts > closestFrame.pts) as Frame;\n\n VERBOSE && console.log('returning previously filtered frame with pts', (closestFrame as Frame).pts);\n closestFramePTS = (closestFrame as Frame).pts;\n outputFrame = closestFrame;\n\n if ((nextFrame && nextFrame.pts > targetPTS) || (closestFramePTS === targetPTS)) {\n // We have a next frame, so we know the frame being displayed at targetPTS is the previous one,\n // which corresponds to outputFrame.\n this.#previousTargetPTS = targetPTS;\n return outputFrame;\n }\n }\n }\n\n // This is the first time we're decoding frames. Get the first packet and decode it.\n if (!this.#packet && this.#frames.length === 0) {\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n this.#packetReadCount++;\n }\n // Read packets until we have a frame which is closest to targetPTS\n while ((this.#packet || this.#frames.length !== 0) && closestFramePTS < targetPTS) {\n VERBOSE && console.log('packet si:', this.#packet?.stream_index, 'pts:', this.#packet?.pts, 'frames:', this.#frames?.length);\n VERBOSE && console.log('frames', this.#frames?.length, 'frames.pts:', JSON.stringify(this.#frames?.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // packet contains frames\n if (this.#frames.length !== 0) {\n // filter the frames\n const filteredResult = await this.#filterer.filter([{ name: 'in0:v', frames: this.#frames }]);\n filteredFrames = filteredResult.flatMap(r => r.frames);\n VERBOSE && console.log('filteredFrames', filteredFrames.length, 'filteredFrames.pts:', JSON.stringify(filteredFrames.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // get the closest frame to our target presentation timestamp (PTS)\n // Beamcoder returns decoded packet frames as follows: [1000, 2000, 3000, 4000]\n // If we're looking for a frame at 0, we want to return the frame at 1000\n // If we're looking for a frame at 2500, we want to return the frame at 2000\n const closestFrame = (this.#packetReadCount === 1 && filteredFrames[0].pts > targetPTS)\n ? filteredFrames[0]\n : filteredFrames.reverse().find(f => f.pts <= targetPTS);\n\n // The packet contains frames, but all of them have PTS larger than our a targetPTS (we looked too far)\n if (!closestFrame) {\n return outputFrame;\n }\n\n // store the filtered packet frames for later reuse\n this.#filteredFramesPacket.unshift(filteredFrames);\n if (this.#filteredFramesPacket.length > 2) {\n this.#filteredFramesPacket.pop();\n }\n\n closestFramePTS = closestFrame?.pts;\n VERBOSE && console.log('closestFramePTS', closestFramePTS, 'targetPTS', targetPTS);\n if (!outputFrame || closestFramePTS <= targetPTS) {\n VERBOSE && console.log('assigning outputFrame', closestFrame?.pts);\n this.#previousTargetPTS = targetPTS;\n outputFrame = closestFrame;\n }\n else {\n // break out of the loop if we've found the closest frame (and ensure we don't move to the next\n // packet by calling _getNextPacketAndDecodeFrames again) as this risks us getting a frame that is\n // after our targetPTS\n VERBOSE && console.log('breaking');\n break;\n }\n }\n // get the next packet and frames\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n\n // keep track of how many packets we've read\n this.#packetReadCount++;\n }\n\n // we read through all the available packets and frames, but we still don't have a frame. This can happen\n // when our targetPTS is to close to the end of the video. In this case, we'll try to seek further away from\n // the end of the video and try again. We've set up a MAX_RECURSION to prevent an infinite loop.\n if (!outputFrame) {\n if (MAX_RECURSION < this.#recursiveReadCount) {\n throw Error('No matching frame found');\n }\n const TIME_OFFSET = 0.1; // time offset in seconds\n const PTSOffset = this._timeToPTS(TIME_OFFSET);\n this.#recursiveReadCount++;\n outputFrame = await this._getFrameAtPts(targetPTS, SeekPTSOffset - PTSOffset);\n if (outputFrame) {\n this.#recursiveReadCount = 0;\n }\n }\n VERBOSE && console.log('read', this.packetReadCount, 'packets');\n\n return outputFrame;\n }\n\n /**\n * Get the next packet from the video stream and decode it into frames. Each frame has a presentation time stamp\n * (PTS). If we've reached the end of the stream and no more packets are available, we'll extract the last frames\n * from the decoder and destroy it.\n */\n async _getNextPacketAndDecodeFrames() {\n const packet = await this._getNextVideoStreamPacket();\n VERBOSE && console.log('packet pts:', packet?.pts);\n\n // extract frames from the packet\n let decodedFrames = null;\n if (packet !== null && this.#decoder) {\n decodedFrames = await this.#decoder.decode(packet as Packet);\n VERBOSE && console.log('decodedFrames', decodedFrames.frames.length, decodedFrames.frames.map(f => f.pts));\n }\n // we've reached the end of the stream\n else {\n if (this.#decoder) {\n VERBOSE && console.log('getting the last frames from the decoder');\n // flush the decoder -- this will return the last frames and destroy the decoder\n decodedFrames = await this.#decoder.flush();\n this.#decoder = null;\n }\n else {\n // we don't have a decoder, so we can't decode any more frames\n VERBOSE && console.log('no more frames to decode');\n }\n }\n\n let frames = [];\n if (decodedFrames && decodedFrames.frames.length !== 0) {\n frames = decodedFrames.frames;\n }\n VERBOSE && console.log(`returning ${frames.length} decoded frames`);\n\n return { packet, frames };\n }\n\n async _getNextVideoStreamPacket(): Promise<null | Packet> {\n VERBOSE && console.log('_getNextVideoStreamPacket');\n\n let packet = await this.#demuxer.read();\n while (packet && packet.stream_index !== this.#streamIndex) {\n packet = await this.#demuxer.read();\n if (packet === null) {\n VERBOSE && console.log('no more packets');\n return null;\n }\n }\n VERBOSE && console.log('returning packet', !!packet, 'pts', packet?.pts, 'si', packet?.stream_index);\n return packet as Packet;\n }\n\n static _setFrameDataToRGBABufferTarget(frame: beamcoder.Frame, rgbaBufferTarget: Uint8ClampedArray) {\n const sourceLineSize = frame.linesize as unknown as number;\n // frame.data can contain multiple \"planes\" in other colorspaces, but in rgba, there is just one \"plane\", so\n // our data is in frame.data[0]\n const pixels = frame.data[0] as Uint8Array;\n const width = frame.width;\n const height = frame.height;\n\n // libav creates larger buffers because it makes their internal code simpler.\n // we have to trim a part at the right of each pixel row.\n\n for (let i = 0; i < height; i++) {\n const sourceStart = i * sourceLineSize;\n const sourceEnd = sourceStart + width * RGBA_PIXEL_SIZE;\n const sourceData = pixels.subarray(sourceStart, sourceEnd);\n const targetOffset = i * width * RGBA_PIXEL_SIZE;\n rgbaBufferTarget.set(sourceData, targetOffset);\n }\n }\n\n async dispose() {\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#demuxer.forceClose();\n this.#filterer = null;\n this.#filteredFramesPacket = undefined;\n this.#frames = [];\n this.#packet = null;\n this.#previousTargetPTS = null;\n this.#streamIndex = 0;\n }\n}\n","import { DownloadVideoURL } from './DownloadVideoURL';\n\ninterface CachedResource {\n url: string;\n filepath: string | undefined;\n download(): Promise<void>;\n destroy(): void;\n}\n\ninterface CacheEntry {\n downloader: DownloadVideoURL;\n refCount: number;\n downloadPromise?: Promise<void>;\n}\n\nexport class CachedVideoDownloader {\n #cache: Map<string, CacheEntry> = new Map();\n\n get(url: string): CachedResource {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n let filepath: string | undefined;\n\n return {\n url,\n get filepath() {\n return filepath;\n },\n\n async download() {\n let entry = self.#cache.get(url);\n\n if (entry) {\n entry.refCount += 1;\n\n // Wait for in-progress download if exists\n if (entry.downloadPromise) {\n await entry.downloadPromise;\n }\n }\n else {\n const downloader = new DownloadVideoURL(url);\n\n const promise = downloader.download();\n entry = {\n downloader,\n refCount: 1,\n downloadPromise: promise,\n };\n self.#cache.set(url, entry);\n\n try {\n await promise;\n }\n finally {\n entry.downloadPromise = undefined; // Clear after completion\n }\n }\n\n filepath = self.#cache.get(url).downloader.filepath;\n },\n\n destroy() {\n const entry = self.#cache.get(url);\n if (!entry) return;\n\n entry.refCount -= 1;\n\n if (entry.refCount <= 0) {\n entry.downloader.clear();\n self.#cache.delete(url);\n }\n\n filepath = undefined;\n },\n };\n }\n}\n"],"names":["BaseExtractor","args","inputFileOrUrl","outputFile","threadCount","endTime","interpolateFps","interpolateMode","targetPts","targetTime","pts","onFrameAvailable","flush","DownloadVideoURL","url","__privateAdd","_url","_httpRequest","_filepath","_tmpObj","__privateSet","extension","path","tmp","__privateGet","source","response","contentType","writeStream","fs","readableStream","reader","resolve","reject","pump","done","value","buffer","RGBA_PIXEL_SIZE","createDecoder","demuxer","streamIndex","commonParams","beamcoder","createFilter","stream","outputPixelFormat","filterSpec","filterSpecStr","STREAM_TYPE_VIDEO","MAX_RECURSION","_BeamcoderExtractor","_createDecoder","_demuxer","_decoder","_filterer","_filteredFramesPacket","_frames","_packet","_previousTargetPTS","_threadCount","_streamIndex","_packetReadCount","_recursiveReadCount","extractor","downloadUrl","pixelFormat","origianlPixelFormat","codecName","s","time_base","rgbaBufferTarget","frame","time","targetPTS","SeekPTSOffset","RE_SEEK_THRESHOLD","hasFrameWithinThreshold","__privateMethod","createDecoder_fn","filteredFrames","closestFramePTS","outputFrame","closestFrame","nextFrame","f","__privateWrapper","r","TIME_OFFSET","PTSOffset","packet","decodedFrames","frames","sourceLineSize","pixels","width","height","i","sourceStart","sourceEnd","sourceData","targetOffset","BeamcoderExtractor","CachedVideoDownloader","_cache","self","filepath","entry","downloader","promise"],"mappings":"8mBAQO,MAAMA,CAAmC,CAC5C,aAAa,OAAOC,EAAyC,CACnD,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,KAAK,CACP,eAAAC,EACA,WAAAC,EACA,YAAAC,EAAc,EACd,QAAAC,EACA,eAAAC,EACA,gBAAAC,CAAA,EAC6B,CACvB,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,UAAmB,CACb,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,OAAgB,CACV,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,QAAiB,CACX,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,UAAUC,EAAmB,CACzB,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,eAAeC,EAAoC,CAC/C,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,mBAAmBA,EAAwC,CACvD,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,cAAcD,EAAmC,CAC7C,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,WAAWC,EAAoB,CAC3B,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAKA,UAAUC,EAAa,CACb,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,WAAW,CACb,iBAAAC,EACA,MAAAC,EAAQ,EAAA,EAOR,CAC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A4F,CACX,EAEA,MAAM,UAAW,CACb,IAAIC,EAAQnF,EAAAiF,EAAKD,GAAO,IAAI1F,CAAG,EAE/B,GAAI6F,EACAA,EAAM,UAAY,EAGdA,EAAM,iBACN,MAAMA,EAAM,oBAGf,CACK,MAAAC,EAAa,IAAI/F,EAAiBC,CAAG,EAErC+F,EAAUD,EAAW,WACnBD,EAAA,CACJ,WAAAC,EACA,SAAU,EACV,gBAAiBC,CAAA,EAEhBrF,EAAAiF,EAAAD,GAAO,IAAI1F,EAAK6F,CAAK,EAEtB,GAAA,CACM,MAAAE,CAAA,QAEV,CACIF,EAAM,gBAAkB,MAC5B,EAGJD,EAAWlF,EAAAiF,EAAKD,GAAO,IAAI1F,CAAG,EAAE,WAAW,QAC/C,EAEA,SAAU,CACN,MAAM6F,EAAQnF,EAAAiF,EAAKD,GAAO,IAAI1F,CAAG,EAC5B6F,IAELA,EAAM,UAAY,EAEdA,EAAM,UAAY,IAClBA,EAAM,WAAW,QACZnF,EAAAiF,EAAAD,GAAO,OAAO1F,CAAG,GAGf4F,EAAA,OACf,CAAA,CAER,CACJ,CA9DIF,EAAA"}
|
|
1
|
+
{"version":3,"file":"framefusion.cjs","sources":["../src/BaseExtractor.ts","../src/DownloadVideoURL.ts","../src/backends/beamcoder.ts","../src/cachedVideoDownloader.ts"],"sourcesContent":["import type {\n ExtractorArgs,\n Frame,\n Extractor\n} from '../framefusion';\nimport type { ImageData } from './types';\n\n\nexport class BaseExtractor implements Extractor {\n static async create(args: ExtractorArgs): Promise<Extractor> {\n throw new Error('Not implemented');\n }\n\n async init({\n inputFileOrUrl,\n outputFile,\n threadCount = 8,\n endTime,\n interpolateFps,\n interpolateMode,\n }: ExtractorArgs): Promise<void> {\n throw new Error('Not implemented');\n }\n\n get duration(): number {\n throw new Error('Not implemented');\n }\n\n get width(): number {\n throw new Error('Not implemented');\n }\n\n get height(): number {\n throw new Error('Not implemented');\n }\n\n async seekToPTS(targetPts: number) {\n throw new Error('Not implemented');\n }\n\n async getFrameAtTime(targetTime: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async getImageDataAtTime(targetTime: number): Promise<ImageData> {\n throw new Error('Not implemented');\n }\n\n async getFrameAtPts(targetPts: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async seekToTime(targetTime: number) {\n throw new Error('Not implemented');\n }\n\n /**\n * Convert a PTS (based on timebase) to PTS (in seconds)\n */\n ptsToTime(pts: number) {\n throw new Error('Not implemented');\n }\n\n async readFrames({\n onFrameAvailable,\n flush = true,\n }: {\n /**\n * Return true if we need to read more frames.\n */\n onFrameAvailable?: (frame: Frame) => Promise<boolean> | boolean;\n flush?: boolean;\n } = {\n flush: true,\n onFrameAvailable: () => true,\n }) {\n throw new Error('Not implemented');\n }\n\n async dispose() {\n throw new Error('Not implemented');\n }\n}\n","import path from 'path';\nimport type { ClientRequest } from 'http';\nimport tmp from 'tmp';\nimport fs from 'fs-extra';\n\n/**\n * Downloads a video file from a given URL as a temporary file. When the object is cleared, the temporary file is\n * deleted.\n */\nexport class DownloadVideoURL {\n #url: string | undefined;\n #httpRequest: ClientRequest | undefined = undefined;\n #filepath: string;\n #tmpObj: tmp.FileResult | undefined = undefined;\n\n constructor(url: string) {\n this.#url = url;\n\n const extension = path.extname(url);\n this.#tmpObj = tmp.fileSync({ postfix: extension });\n this.#filepath = this.#tmpObj.name;\n }\n\n /**\n * returns the filepath of the downloaded file. If the file has not been downloaded yet, it will be undefined\n */\n get filepath() {\n return this.#filepath;\n }\n\n /**\n * Downloads the file from the given URL. The file will be downloaded to a temporary file.\n */\n async download() {\n const source = this.#url;\n\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch ${source}, status: ${response.status}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n if (!contentType || !contentType.includes('video')) {\n throw new Error(\n `Source ${source}, returned unsupported content type ${contentType}`\n );\n }\n\n const writeStream = fs.createWriteStream(this.#tmpObj.name);\n const readableStream = response.body;\n\n if (!readableStream) {\n throw new Error(`Response body is null for ${source}`);\n }\n\n const reader = readableStream.getReader();\n\n return new Promise<void>((resolve, reject) => {\n const pump = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n writeStream.end(() => {\n this.#filepath = this.#tmpObj.name;\n resolve();\n });\n return;\n }\n const buffer = Buffer.from(value);\n if (!writeStream.write(buffer)) {\n // Wait for 'drain' before continuing\n writeStream.once('drain', pump);\n }\n else {\n pump();\n }\n }).catch(reject);\n };\n\n writeStream.on('error', reject);\n pump();\n });\n }\n\n clear() {\n if (this.#tmpObj) this.#tmpObj.removeCallback();\n if (this.#url) this.#url = undefined;\n if (this.#httpRequest) this.#httpRequest = null;\n if (this.#filepath) this.#filepath = undefined;\n }\n}\n","import type {\n Packet,\n Demuxer,\n Decoder,\n Filterer,\n Frame\n} from '@lumen5/beamcoder';\nimport beamcoder from '@lumen5/beamcoder';\nimport type { ImageData } from '../types';\nimport { BaseExtractor } from '../BaseExtractor';\nimport type { Extractor, ExtractorArgs, InterpolateMode } from '../../framefusion';\nimport { DownloadVideoURL } from '../DownloadVideoURL';\n\nconst VERBOSE = false;\n\n/**\n * RGBA format need one byte for every components: r, g, b and a\n */\nexport const RGBA_PIXEL_SIZE = 4;\n\nconst createDecoder = ({\n demuxer,\n streamIndex,\n threadCount,\n}: {\n demuxer: Demuxer;\n streamIndex: number;\n threadCount: number;\n}): Decoder => {\n const commonParams = {\n width: demuxer.streams[streamIndex].codecpar.width,\n height: demuxer.streams[streamIndex].codecpar.height,\n pix_fmt: demuxer.streams[streamIndex].codecpar.format,\n thread_count: threadCount,\n };\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp8') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx',\n });\n }\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp9') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx-vp9',\n });\n }\n\n return beamcoder.decoder({\n ...commonParams,\n demuxer: demuxer,\n stream_index: streamIndex,\n });\n};\n\n/**\n * A filter to convert between color spaces.\n * An example would be YUV to RGB, for mp4 to png conversion.\n */\nconst createFilter = async({\n stream,\n outputPixelFormat,\n interpolateFps,\n interpolateMode = 'fast',\n}: {\n stream: beamcoder.Stream;\n outputPixelFormat: string;\n interpolateFps?: number;\n interpolateMode?: InterpolateMode;\n}): Promise<beamcoder.Filterer> => {\n if (!stream.codecpar.format) {\n return null;\n }\n\n let filterSpec = [`[in0:v]format=${stream.codecpar.format}`];\n\n if (interpolateFps) {\n if (interpolateMode === 'high-quality') {\n filterSpec = [...filterSpec, `minterpolate=fps=${interpolateFps}`];\n }\n else if (interpolateMode === 'fast') {\n filterSpec = [...filterSpec, `fps=${interpolateFps}`];\n }\n else {\n throw new Error(`Unexpected interpolation mode: ${interpolateMode}`);\n }\n }\n\n const filterSpecStr = filterSpec.join(', ') + '[out0:v]';\n\n VERBOSE && console.log(`filterSpec: ${filterSpecStr}`);\n\n return beamcoder.filterer({\n filterType: 'video',\n inputParams: [\n {\n name: 'in0:v',\n width: stream.codecpar.width,\n height: stream.codecpar.height,\n pixelFormat: stream.codecpar.format,\n timeBase: stream.time_base,\n pixelAspect: stream.sample_aspect_ratio,\n },\n ],\n outputParams: [\n {\n name: 'out0:v',\n pixelFormat: outputPixelFormat,\n },\n ],\n filterSpec: filterSpecStr,\n });\n};\n\nconst STREAM_TYPE_VIDEO = 'video';\nconst STREAM_TYPE_AUDIO = 'audio';\nconst MAX_RECURSION = 5;\n\n/**\n * A simple extractor that uses beamcoder to extract frames from a video file.\n */\nexport class BeamcoderExtractor extends BaseExtractor implements Extractor {\n /**\n * The demuxer reads the file and outputs packet streams\n */\n #demuxer: Demuxer = null;\n\n /**\n * The decoder reads packets and can output raw frame data\n */\n #decoder: Decoder = null;\n\n /**\n * Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or\n * filters, filter might not be necessary.\n */\n #filterer: Filterer = null;\n\n /**\n * This is where we store filtered frames from each previously processed packet.\n * We keep these in chronological order. We hang on to them for two reasons:\n * 1. so we can return them if we get a request for the same time again\n * 2. so we can return frames close the end of the stream. When such a frame is requested we have to flush (destroy)\n * the encoder to get the last few frames. This avoids having to re-create an encoder.\n */\n #filteredFramesPacket: undefined[] | Array<Array<Frame>> = [];\n\n /**\n * This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We\n * do this ensure we don't skip any frames.\n */\n #frames = [];\n\n /**\n * This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do\n * this ensure we don't skip any frames.\n */\n #packet: null | Packet = null;\n\n /**\n * The last target presentation timestamp (PTS) we requested. If we never requested a time(stamp) then this\n * value is null\n */\n #previousTargetPTS: null | number = null;\n\n /**\n * The number of threads to use for decoding\n */\n #threadCount = 8;\n\n /**\n * The index of the video stream in the demuxer\n */\n #streamIndex = 0;\n\n /**\n * The number of packets we've read from the demuxer to complete the frame query\n * @private\n */\n #packetReadCount = 0;\n\n /**\n * The number of times we've recursively read packets from the demuxer to complete the frame query\n * @private\n */\n #recursiveReadCount = 0;\n\n /**\n * Encoder/Decoder construction is async, so it can't be put in a regular constructor.\n * Use and await this method to generate an extractor.\n */\n static async create(args: ExtractorArgs): Promise<BeamcoderExtractor> {\n const extractor = new BeamcoderExtractor();\n await extractor.init(args);\n return extractor;\n }\n\n async init({\n inputFileOrUrl,\n threadCount = 8,\n outputPixelFormat = 'rgba',\n }: ExtractorArgs): Promise<void> {\n this.#threadCount = threadCount;\n VERBOSE && console.log('inputFileOrUrl before pre-processing: ', inputFileOrUrl);\n if (inputFileOrUrl.startsWith('http')) {\n VERBOSE && console.log('downloading url', inputFileOrUrl);\n const downloadUrl = new DownloadVideoURL(inputFileOrUrl);\n await downloadUrl.download();\n inputFileOrUrl = downloadUrl.filepath;\n VERBOSE && console.log('finished downloading');\n }\n // Assume file url at this point\n if (!inputFileOrUrl.startsWith('file:')) {\n inputFileOrUrl = 'file:' + inputFileOrUrl;\n }\n VERBOSE && console.log('inputFileOrUrl after pre-processing: ', inputFileOrUrl);\n VERBOSE && console.log('beamcoder.protocols(): ', JSON.stringify(beamcoder.protocols()));\n this.#demuxer = await beamcoder.demuxer(inputFileOrUrl);\n VERBOSE && console.log('demuxer creation succeeded.');\n this.#streamIndex = this.#demuxer.streams.findIndex(stream => stream.codecpar.codec_type === STREAM_TYPE_VIDEO);\n\n if (this.#streamIndex === -1) {\n throw new Error(`File has no ${STREAM_TYPE_VIDEO} stream!`);\n }\n let pixelFormat = 'rgba';\n const origianlPixelFormat = this.#demuxer.streams[this.#streamIndex].codecpar.format;\n const codecName = this.#demuxer.streams[this.#streamIndex].codecpar.name;\n // vp8 and vp9 this.#demuxer.streams[this.#streamIndex].codecpar.format is 'yuv420p', but the decoder outputs yuva420p\n if (outputPixelFormat === 'original' && codecName !== 'vp8' && codecName !== 'vp9') {\n pixelFormat = origianlPixelFormat;\n }\n this.#filterer = await createFilter({\n stream: this.#demuxer.streams[this.#streamIndex],\n outputPixelFormat: pixelFormat,\n });\n }\n\n async #createDecoder() {\n // It's possible that we need to create decoder multiple times during the lifecycle of this extractor so we\n // need to make sure we destroy the old one first if it exists\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#decoder = createDecoder({\n demuxer: this.#demuxer as Demuxer,\n streamIndex: this.#streamIndex,\n threadCount: this.#threadCount,\n });\n }\n\n get duration(): number {\n // Non-A/V streams (timed-text, data) can carry durations unrelated to playback;\n // taking the max over them would inflate the reported duration.\n const maxStreamsDuration = Math.max(...this.#demuxer.streams\n .filter(s => s.codecpar.codec_type === STREAM_TYPE_VIDEO || s.codecpar.codec_type === STREAM_TYPE_AUDIO)\n .map(s => {\n const time_base = s.time_base;\n return s.duration * time_base[0] / time_base[1];\n }));\n // Webm stores it in Segment.Info.Duration\n return maxStreamsDuration || (this.ptsToTime(this.#demuxer.duration) / 1000);\n }\n\n /**\n * Width in pixels\n */\n get width(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.width;\n }\n\n /**\n * Height in pixels\n */\n get height(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.height;\n }\n\n /**\n * Get the beamcoder Frame for a given time in seconds\n * @param targetTime\n */\n async getFrameAtTime(targetTime: number): Promise<beamcoder.Frame> {\n VERBOSE && console.log(`getFrameAtTime time(s)=${targetTime}`);\n const targetPts = Math.round(this._timeToPTS(targetTime));\n return this._getFrameAtPts(targetPts);\n }\n\n /**\n * Get imageData for a given time in seconds\n * @param targetTime\n */\n async getImageDataAtTime(targetTime: number, rgbaBufferTarget?: Uint8ClampedArray): Promise<ImageData> {\n const targetPts = Math.round(this._timeToPTS(targetTime));\n VERBOSE && console.log('targetTime', targetTime, '-> targetPts', targetPts);\n const frame = await this._getFrameAtPts(targetPts);\n if (!frame) {\n VERBOSE && console.log('no frame found');\n return null;\n }\n\n if (rgbaBufferTarget) {\n BeamcoderExtractor._setFrameDataToRGBABufferTarget(frame, rgbaBufferTarget);\n }\n\n return {\n width: frame.width,\n height: frame.height,\n frame,\n };\n }\n\n /**\n * Get the presentation timestamp (PTS) for a given time in seconds\n */\n _timeToPTS(time: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return time * time_base[1] / time_base[0];\n }\n\n /**\n * Get the time in seconds from a given presentation timestamp (PTS)\n */\n ptsToTime(pts: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return pts * time_base[0] / time_base[1];\n }\n\n get packetReadCount() {\n return this.#packetReadCount;\n }\n\n /**\n * Get the frame at the given presentation timestamp (PTS)\n * @param targetPTS - the target presentation timestamp (PTS) we want to retrieve\n * @param SeekPTSOffset - the offset to use when seeking to the targetPTS. This is used when we have trouble finding\n * the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read\n * additional packets and find a frame that is closer to the targetPTS.\n */\n async _getFrameAtPts(targetPTS: number, SeekPTSOffset = 0): Promise<beamcoder.Frame> {\n VERBOSE && console.log('_getFrameAtPts', targetPTS, 'seekPTSOffset', SeekPTSOffset, 'duration', this.duration);\n this.#packetReadCount = 0;\n\n // seek and create a decoder when retrieving a frame for the first time or when seeking backwards\n // we have to create a new decoder when seeking backwards as the decoder can only process frames in\n // chronological order.\n // RE_SEEK_DELTA: sometimes, we are looking for a frame so far ahead that it's better to drop everything and seek.\n // Example: when we got a frame a 0 and request a frame at t = 30s just after, we don't want to start reading all packets\n // until 30s.\n const RE_SEEK_THRESHOLD = 3; // 3 seconds - typically we have keyframes at shorter intervals\n const hasFrameWithinThreshold = this.#filteredFramesPacket.flat().some(frame => {\n return this.ptsToTime(Math.abs(targetPTS - (frame as Frame).pts)) < RE_SEEK_THRESHOLD;\n });\n VERBOSE && console.log('hasPreviousTargetPTS:', this.#previousTargetPTS === null, ', targetPTS is smaller:', this.#previousTargetPTS > targetPTS, ', has frame within threshold:', hasFrameWithinThreshold);\n if (this.#previousTargetPTS === null || this.#previousTargetPTS > targetPTS || !hasFrameWithinThreshold) {\n VERBOSE && console.log(`Seeking to ${targetPTS + SeekPTSOffset}`);\n\n await this.#demuxer.seek({\n stream_index: 0, // even though we specify the stream index, it still seeks all streams\n timestamp: targetPTS + SeekPTSOffset,\n any: false,\n });\n await this.#createDecoder();\n this.#packet = null;\n this.#frames = [];\n this.#previousTargetPTS = targetPTS;\n this.#filteredFramesPacket = [];\n }\n\n let filteredFrames = null;\n let closestFramePTS = -1;\n let outputFrame = null;\n\n // If we have previously filtered frames, get the frame closest to our targetPTS\n if (this.#filteredFramesPacket.length > 0) {\n const closestFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts <= targetPTS) as Frame;\n\n if (closestFrame) {\n const nextFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts > closestFrame.pts) as Frame;\n\n VERBOSE && console.log('returning previously filtered frame with pts', (closestFrame as Frame).pts);\n closestFramePTS = (closestFrame as Frame).pts;\n outputFrame = closestFrame;\n\n if ((nextFrame && nextFrame.pts > targetPTS) || (closestFramePTS === targetPTS)) {\n // We have a next frame, so we know the frame being displayed at targetPTS is the previous one,\n // which corresponds to outputFrame.\n this.#previousTargetPTS = targetPTS;\n return outputFrame;\n }\n }\n }\n\n // This is the first time we're decoding frames. Get the first packet and decode it.\n if (!this.#packet && this.#frames.length === 0) {\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n this.#packetReadCount++;\n }\n // Read packets until we have a frame which is closest to targetPTS\n while ((this.#packet || this.#frames.length !== 0) && closestFramePTS < targetPTS) {\n VERBOSE && console.log('packet si:', this.#packet?.stream_index, 'pts:', this.#packet?.pts, 'frames:', this.#frames?.length);\n VERBOSE && console.log('frames', this.#frames?.length, 'frames.pts:', JSON.stringify(this.#frames?.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // packet contains frames\n if (this.#frames.length !== 0) {\n // filter the frames\n const filteredResult = await this.#filterer.filter([{ name: 'in0:v', frames: this.#frames }]);\n filteredFrames = filteredResult.flatMap(r => r.frames);\n VERBOSE && console.log('filteredFrames', filteredFrames.length, 'filteredFrames.pts:', JSON.stringify(filteredFrames.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // get the closest frame to our target presentation timestamp (PTS)\n // Beamcoder returns decoded packet frames as follows: [1000, 2000, 3000, 4000]\n // If we're looking for a frame at 0, we want to return the frame at 1000\n // If we're looking for a frame at 2500, we want to return the frame at 2000\n const closestFrame = (this.#packetReadCount === 1 && filteredFrames[0].pts > targetPTS)\n ? filteredFrames[0]\n : filteredFrames.reverse().find(f => f.pts <= targetPTS);\n\n // The packet contains frames, but all of them have PTS larger than our a targetPTS (we looked too far)\n if (!closestFrame) {\n return outputFrame;\n }\n\n // store the filtered packet frames for later reuse\n this.#filteredFramesPacket.unshift(filteredFrames);\n if (this.#filteredFramesPacket.length > 2) {\n this.#filteredFramesPacket.pop();\n }\n\n closestFramePTS = closestFrame?.pts;\n VERBOSE && console.log('closestFramePTS', closestFramePTS, 'targetPTS', targetPTS);\n if (!outputFrame || closestFramePTS <= targetPTS) {\n VERBOSE && console.log('assigning outputFrame', closestFrame?.pts);\n this.#previousTargetPTS = targetPTS;\n outputFrame = closestFrame;\n }\n else {\n // break out of the loop if we've found the closest frame (and ensure we don't move to the next\n // packet by calling _getNextPacketAndDecodeFrames again) as this risks us getting a frame that is\n // after our targetPTS\n VERBOSE && console.log('breaking');\n break;\n }\n }\n // get the next packet and frames\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n\n // keep track of how many packets we've read\n this.#packetReadCount++;\n }\n\n // we read through all the available packets and frames, but we still don't have a frame. This can happen\n // when our targetPTS is to close to the end of the video. In this case, we'll try to seek further away from\n // the end of the video and try again. We've set up a MAX_RECURSION to prevent an infinite loop.\n if (!outputFrame) {\n if (MAX_RECURSION < this.#recursiveReadCount) {\n throw Error('No matching frame found');\n }\n const TIME_OFFSET = 0.1; // time offset in seconds\n const PTSOffset = this._timeToPTS(TIME_OFFSET);\n this.#recursiveReadCount++;\n outputFrame = await this._getFrameAtPts(targetPTS, SeekPTSOffset - PTSOffset);\n if (outputFrame) {\n this.#recursiveReadCount = 0;\n }\n }\n VERBOSE && console.log('read', this.packetReadCount, 'packets');\n\n return outputFrame;\n }\n\n /**\n * Get the next packet from the video stream and decode it into frames. Each frame has a presentation time stamp\n * (PTS). If we've reached the end of the stream and no more packets are available, we'll extract the last frames\n * from the decoder and destroy it.\n */\n async _getNextPacketAndDecodeFrames() {\n const packet = await this._getNextVideoStreamPacket();\n VERBOSE && console.log('packet pts:', packet?.pts);\n\n // extract frames from the packet\n let decodedFrames = null;\n if (packet !== null && this.#decoder) {\n decodedFrames = await this.#decoder.decode(packet as Packet);\n VERBOSE && console.log('decodedFrames', decodedFrames.frames.length, decodedFrames.frames.map(f => f.pts));\n }\n // we've reached the end of the stream\n else {\n if (this.#decoder) {\n VERBOSE && console.log('getting the last frames from the decoder');\n // flush the decoder -- this will return the last frames and destroy the decoder\n decodedFrames = await this.#decoder.flush();\n this.#decoder = null;\n }\n else {\n // we don't have a decoder, so we can't decode any more frames\n VERBOSE && console.log('no more frames to decode');\n }\n }\n\n let frames = [];\n if (decodedFrames && decodedFrames.frames.length !== 0) {\n frames = decodedFrames.frames;\n }\n VERBOSE && console.log(`returning ${frames.length} decoded frames`);\n\n return { packet, frames };\n }\n\n async _getNextVideoStreamPacket(): Promise<null | Packet> {\n VERBOSE && console.log('_getNextVideoStreamPacket');\n\n let packet = await this.#demuxer.read();\n while (packet && packet.stream_index !== this.#streamIndex) {\n packet = await this.#demuxer.read();\n if (packet === null) {\n VERBOSE && console.log('no more packets');\n return null;\n }\n }\n VERBOSE && console.log('returning packet', !!packet, 'pts', packet?.pts, 'si', packet?.stream_index);\n return packet as Packet;\n }\n\n static _setFrameDataToRGBABufferTarget(frame: beamcoder.Frame, rgbaBufferTarget: Uint8ClampedArray) {\n const sourceLineSize = frame.linesize as unknown as number;\n // frame.data can contain multiple \"planes\" in other colorspaces, but in rgba, there is just one \"plane\", so\n // our data is in frame.data[0]\n const pixels = frame.data[0] as Uint8Array;\n const width = frame.width;\n const height = frame.height;\n\n // libav creates larger buffers because it makes their internal code simpler.\n // we have to trim a part at the right of each pixel row.\n\n for (let i = 0; i < height; i++) {\n const sourceStart = i * sourceLineSize;\n const sourceEnd = sourceStart + width * RGBA_PIXEL_SIZE;\n const sourceData = pixels.subarray(sourceStart, sourceEnd);\n const targetOffset = i * width * RGBA_PIXEL_SIZE;\n rgbaBufferTarget.set(sourceData, targetOffset);\n }\n }\n\n async dispose() {\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#demuxer.forceClose();\n this.#filterer = null;\n this.#filteredFramesPacket = undefined;\n this.#frames = [];\n this.#packet = null;\n this.#previousTargetPTS = null;\n this.#streamIndex = 0;\n }\n}\n","import { DownloadVideoURL } from './DownloadVideoURL';\n\ninterface CachedResource {\n url: string;\n filepath: string | undefined;\n download(): Promise<void>;\n destroy(): void;\n}\n\ninterface CacheEntry {\n downloader: DownloadVideoURL;\n refCount: number;\n downloadPromise?: Promise<void>;\n}\n\nexport class CachedVideoDownloader {\n #cache: Map<string, CacheEntry> = new Map();\n\n get(url: string): CachedResource {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n let filepath: string | undefined;\n\n return {\n url,\n get filepath() {\n return filepath;\n },\n\n async download() {\n let entry = self.#cache.get(url);\n\n if (entry) {\n entry.refCount += 1;\n\n // Wait for in-progress download if exists\n if (entry.downloadPromise) {\n await entry.downloadPromise;\n }\n }\n else {\n const downloader = new DownloadVideoURL(url);\n\n const promise = downloader.download();\n entry = {\n downloader,\n refCount: 1,\n downloadPromise: promise,\n };\n self.#cache.set(url, entry);\n\n try {\n await promise;\n }\n finally {\n entry.downloadPromise = undefined; // Clear after completion\n }\n }\n\n filepath = self.#cache.get(url).downloader.filepath;\n },\n\n destroy() {\n const entry = self.#cache.get(url);\n if (!entry) return;\n\n entry.refCount -= 1;\n\n if (entry.refCount <= 0) {\n entry.downloader.clear();\n self.#cache.delete(url);\n }\n\n filepath = undefined;\n },\n };\n }\n}\n"],"names":["BaseExtractor","args","inputFileOrUrl","outputFile","threadCount","endTime","interpolateFps","interpolateMode","targetPts","targetTime","pts","onFrameAvailable","flush","DownloadVideoURL","url","__privateAdd","_url","_httpRequest","_filepath","_tmpObj","__privateSet","extension","path","tmp","__privateGet","source","response","contentType","writeStream","fs","readableStream","reader","resolve","reject","pump","done","value","buffer","RGBA_PIXEL_SIZE","createDecoder","demuxer","streamIndex","commonParams","beamcoder","createFilter","stream","outputPixelFormat","filterSpec","filterSpecStr","STREAM_TYPE_VIDEO","STREAM_TYPE_AUDIO","MAX_RECURSION","_BeamcoderExtractor","_createDecoder","_demuxer","_decoder","_filterer","_filteredFramesPacket","_frames","_packet","_previousTargetPTS","_threadCount","_streamIndex","_packetReadCount","_recursiveReadCount","extractor","downloadUrl","pixelFormat","origianlPixelFormat","codecName","time_base","rgbaBufferTarget","frame","time","targetPTS","SeekPTSOffset","RE_SEEK_THRESHOLD","hasFrameWithinThreshold","__privateMethod","createDecoder_fn","filteredFrames","closestFramePTS","outputFrame","closestFrame","nextFrame","f","__privateWrapper","r","TIME_OFFSET","PTSOffset","packet","decodedFrames","frames","sourceLineSize","pixels","width","height","i","sourceStart","sourceEnd","sourceData","targetOffset","BeamcoderExtractor","CachedVideoDownloader","_cache","self","filepath","entry","downloader","promise"],"mappings":"8mBAQO,MAAMA,CAAmC,CAC5C,aAAa,OAAOC,EAAyC,CACnD,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,KAAK,CACP,eAAAC,EACA,WAAAC,EACA,YAAAC,EAAc,EACd,QAAAC,EACA,eAAAC,EACA,gBAAAC,CAAA,EAC6B,CACvB,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,UAAmB,CACb,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,OAAgB,CACV,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,IAAI,QAAiB,CACX,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,UAAUC,EAAmB,CACzB,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,eAAeC,EAAoC,CAC/C,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,mBAAmBA,EAAwC,CACvD,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,cAAcD,EAAmC,CAC7C,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,WAAWC,EAAoB,CAC3B,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAKA,UAAUC,EAAa,CACb,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,WAAW,CACb,iBAAAC,EACA,MAAAC,EAAQ,EAAA,EAOR,CACA,MAAO,GACP,iBAAkB,IAAM,EAAA,EACzB,CACO,MAAA,IAAI,MAAM,iBAAiB,CACrC,CAEA,MAAM,SAAU,CACN,MAAA,IAAI,MAAM,iBAAiB,CACrC,CACJ,aCzEO,MAAMC,CAAiB,CAM1B,YAAYC,EAAa,CALzBC,EAAA,KAAAC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EAGdA,EAAM,iBACN,MAAMA,EAAM,oBAGf,CACK,MAAAC,EAAa,IAAI/F,EAAiBC,CAAG,EAErC+F,EAAUD,EAAW,WACnBD,EAAA,CACJ,WAAAC,EACA,SAAU,EACV,gBAAiBC,CAAA,EAEhBrF,EAAAiF,EAAAD,GAAO,IAAI1F,EAAK6F,CAAK,EAEtB,GAAA,CACM,MAAAE,CAAA,QAEV,CACIF,EAAM,gBAAkB,MAC5B,EAGJD,EAAWlF,EAAAiF,EAAKD,GAAO,IAAI1F,CAAG,EAAE,WAAW,QAC/C,EAEA,SAAU,CACN,MAAM6F,EAAQnF,EAAAiF,EAAKD,GAAO,IAAI1F,CAAG,EAC5B6F,IAELA,EAAM,UAAY,EAEdA,EAAM,UAAY,IAClBA,EAAM,WAAW,QACZnF,EAAAiF,EAAAD,GAAO,OAAO1F,CAAG,GAGf4F,EAAA,OACf,CAAA,CAER,CACJ,CA9DIF,EAAA"}
|
package/dist/framefusion.es.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var B = (a,
|
|
2
|
-
if (!
|
|
1
|
+
var B = (a, i, t) => {
|
|
2
|
+
if (!i.has(a))
|
|
3
3
|
throw TypeError("Cannot " + t);
|
|
4
4
|
};
|
|
5
|
-
var e = (a,
|
|
6
|
-
if (
|
|
5
|
+
var e = (a, i, t) => (B(a, i, "read from private field"), t ? t.call(a) : i.get(a)), m = (a, i, t) => {
|
|
6
|
+
if (i.has(a))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
|
|
9
|
-
}, o = (a,
|
|
8
|
+
i instanceof WeakSet ? i.add(a) : i.set(a, t);
|
|
9
|
+
}, o = (a, i, t, s) => (B(a, i, "write to private field"), s ? s.call(a, t) : i.set(a, t), t), F = (a, i, t, s) => ({
|
|
10
10
|
set _(r) {
|
|
11
|
-
o(a,
|
|
11
|
+
o(a, i, r, t);
|
|
12
12
|
},
|
|
13
13
|
get _() {
|
|
14
|
-
return e(a,
|
|
14
|
+
return e(a, i, s);
|
|
15
15
|
}
|
|
16
|
-
}),
|
|
16
|
+
}), V = (a, i, t) => (B(a, i, "access private method"), t);
|
|
17
17
|
import R from "@lumen5/beamcoder";
|
|
18
18
|
import z from "path";
|
|
19
19
|
import H from "tmp";
|
|
20
|
-
import
|
|
21
|
-
class
|
|
22
|
-
static async create(
|
|
20
|
+
import O from "fs-extra";
|
|
21
|
+
class X {
|
|
22
|
+
static async create(i) {
|
|
23
23
|
throw new Error("Not implemented");
|
|
24
24
|
}
|
|
25
25
|
async init({
|
|
26
|
-
inputFileOrUrl:
|
|
26
|
+
inputFileOrUrl: i,
|
|
27
27
|
outputFile: t,
|
|
28
|
-
threadCount:
|
|
28
|
+
threadCount: s = 8,
|
|
29
29
|
endTime: r,
|
|
30
30
|
interpolateFps: h,
|
|
31
|
-
interpolateMode:
|
|
31
|
+
interpolateMode: d
|
|
32
32
|
}) {
|
|
33
33
|
throw new Error("Not implemented");
|
|
34
34
|
}
|
|
@@ -41,29 +41,29 @@ class j {
|
|
|
41
41
|
get height() {
|
|
42
42
|
throw new Error("Not implemented");
|
|
43
43
|
}
|
|
44
|
-
async seekToPTS(
|
|
44
|
+
async seekToPTS(i) {
|
|
45
45
|
throw new Error("Not implemented");
|
|
46
46
|
}
|
|
47
|
-
async getFrameAtTime(
|
|
47
|
+
async getFrameAtTime(i) {
|
|
48
48
|
throw new Error("Not implemented");
|
|
49
49
|
}
|
|
50
|
-
async getImageDataAtTime(
|
|
50
|
+
async getImageDataAtTime(i) {
|
|
51
51
|
throw new Error("Not implemented");
|
|
52
52
|
}
|
|
53
|
-
async getFrameAtPts(
|
|
53
|
+
async getFrameAtPts(i) {
|
|
54
54
|
throw new Error("Not implemented");
|
|
55
55
|
}
|
|
56
|
-
async seekToTime(
|
|
56
|
+
async seekToTime(i) {
|
|
57
57
|
throw new Error("Not implemented");
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Convert a PTS (based on timebase) to PTS (in seconds)
|
|
61
61
|
*/
|
|
62
|
-
ptsToTime(
|
|
62
|
+
ptsToTime(i) {
|
|
63
63
|
throw new Error("Not implemented");
|
|
64
64
|
}
|
|
65
65
|
async readFrames({
|
|
66
|
-
onFrameAvailable:
|
|
66
|
+
onFrameAvailable: i,
|
|
67
67
|
flush: t = !0
|
|
68
68
|
} = {
|
|
69
69
|
flush: !0,
|
|
@@ -77,13 +77,13 @@ class j {
|
|
|
77
77
|
}
|
|
78
78
|
var P, D, x, E;
|
|
79
79
|
class G {
|
|
80
|
-
constructor(
|
|
80
|
+
constructor(i) {
|
|
81
81
|
m(this, P, void 0);
|
|
82
82
|
m(this, D, void 0);
|
|
83
83
|
m(this, x, void 0);
|
|
84
84
|
m(this, E, void 0);
|
|
85
|
-
o(this, P,
|
|
86
|
-
const t = z.extname(
|
|
85
|
+
o(this, P, i);
|
|
86
|
+
const t = z.extname(i);
|
|
87
87
|
o(this, E, H.fileSync({ postfix: t })), o(this, x, e(this, E).name);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
@@ -96,34 +96,34 @@ class G {
|
|
|
96
96
|
* Downloads the file from the given URL. The file will be downloaded to a temporary file.
|
|
97
97
|
*/
|
|
98
98
|
async download() {
|
|
99
|
-
const
|
|
99
|
+
const i = e(this, P), t = await fetch(i);
|
|
100
100
|
if (!t.ok)
|
|
101
101
|
throw new Error(
|
|
102
|
-
`Failed to fetch ${
|
|
102
|
+
`Failed to fetch ${i}, status: ${t.status}`
|
|
103
103
|
);
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
104
|
+
const s = t.headers.get("content-type");
|
|
105
|
+
if (!s || !s.includes("video"))
|
|
106
106
|
throw new Error(
|
|
107
|
-
`Source ${
|
|
107
|
+
`Source ${i}, returned unsupported content type ${s}`
|
|
108
108
|
);
|
|
109
|
-
const r =
|
|
109
|
+
const r = O.createWriteStream(e(this, E).name), h = t.body;
|
|
110
110
|
if (!h)
|
|
111
|
-
throw new Error(`Response body is null for ${
|
|
112
|
-
const
|
|
111
|
+
throw new Error(`Response body is null for ${i}`);
|
|
112
|
+
const d = h.getReader();
|
|
113
113
|
return new Promise((w, n) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
114
|
+
const l = () => {
|
|
115
|
+
d.read().then(({ done: f, value: y }) => {
|
|
116
116
|
if (f) {
|
|
117
117
|
r.end(() => {
|
|
118
118
|
o(this, x, e(this, E).name), w();
|
|
119
119
|
});
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
const M = Buffer.from(
|
|
123
|
-
r.write(M) ?
|
|
122
|
+
const M = Buffer.from(y);
|
|
123
|
+
r.write(M) ? l() : r.once("drain", l);
|
|
124
124
|
}).catch(n);
|
|
125
125
|
};
|
|
126
|
-
r.on("error", n),
|
|
126
|
+
r.on("error", n), l();
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
clear() {
|
|
@@ -131,44 +131,44 @@ class G {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
P = new WeakMap(), D = new WeakMap(), x = new WeakMap(), E = new WeakMap();
|
|
134
|
-
const
|
|
134
|
+
const L = 4, Y = ({
|
|
135
135
|
demuxer: a,
|
|
136
|
-
streamIndex:
|
|
136
|
+
streamIndex: i,
|
|
137
137
|
threadCount: t
|
|
138
138
|
}) => {
|
|
139
|
-
const
|
|
140
|
-
width: a.streams[
|
|
141
|
-
height: a.streams[
|
|
142
|
-
pix_fmt: a.streams[
|
|
139
|
+
const s = {
|
|
140
|
+
width: a.streams[i].codecpar.width,
|
|
141
|
+
height: a.streams[i].codecpar.height,
|
|
142
|
+
pix_fmt: a.streams[i].codecpar.format,
|
|
143
143
|
thread_count: t
|
|
144
144
|
};
|
|
145
|
-
return a.streams[
|
|
146
|
-
...
|
|
145
|
+
return a.streams[i].codecpar.name === "vp8" ? R.decoder({
|
|
146
|
+
...s,
|
|
147
147
|
name: "libvpx"
|
|
148
|
-
}) : a.streams[
|
|
149
|
-
...
|
|
148
|
+
}) : a.streams[i].codecpar.name === "vp9" ? R.decoder({
|
|
149
|
+
...s,
|
|
150
150
|
name: "libvpx-vp9"
|
|
151
151
|
}) : R.decoder({
|
|
152
|
-
...
|
|
152
|
+
...s,
|
|
153
153
|
demuxer: a,
|
|
154
|
-
stream_index:
|
|
154
|
+
stream_index: i
|
|
155
155
|
});
|
|
156
|
-
},
|
|
156
|
+
}, j = async ({
|
|
157
157
|
stream: a,
|
|
158
|
-
outputPixelFormat:
|
|
158
|
+
outputPixelFormat: i,
|
|
159
159
|
interpolateFps: t,
|
|
160
|
-
interpolateMode:
|
|
160
|
+
interpolateMode: s = "fast"
|
|
161
161
|
}) => {
|
|
162
162
|
if (!a.codecpar.format)
|
|
163
163
|
return null;
|
|
164
164
|
let r = [`[in0:v]format=${a.codecpar.format}`];
|
|
165
165
|
if (t)
|
|
166
|
-
if (
|
|
166
|
+
if (s === "high-quality")
|
|
167
167
|
r = [...r, `minterpolate=fps=${t}`];
|
|
168
|
-
else if (
|
|
168
|
+
else if (s === "fast")
|
|
169
169
|
r = [...r, `fps=${t}`];
|
|
170
170
|
else
|
|
171
|
-
throw new Error(`Unexpected interpolation mode: ${
|
|
171
|
+
throw new Error(`Unexpected interpolation mode: ${s}`);
|
|
172
172
|
const h = r.join(", ") + "[out0:v]";
|
|
173
173
|
return R.filterer({
|
|
174
174
|
filterType: "video",
|
|
@@ -185,17 +185,17 @@ const V = 4, K = ({
|
|
|
185
185
|
outputParams: [
|
|
186
186
|
{
|
|
187
187
|
name: "out0:v",
|
|
188
|
-
pixelFormat:
|
|
188
|
+
pixelFormat: i
|
|
189
189
|
}
|
|
190
190
|
],
|
|
191
191
|
filterSpec: h
|
|
192
192
|
});
|
|
193
|
-
},
|
|
194
|
-
var c, p,
|
|
195
|
-
const $ = class extends
|
|
193
|
+
}, I = "video", K = "audio", Z = 5;
|
|
194
|
+
var c, p, N, g, _, T, v, S, u, b, k, C, q;
|
|
195
|
+
const $ = class extends X {
|
|
196
196
|
constructor() {
|
|
197
197
|
super(...arguments);
|
|
198
|
-
m(this,
|
|
198
|
+
m(this, C);
|
|
199
199
|
/**
|
|
200
200
|
* The demuxer reads the file and outputs packet streams
|
|
201
201
|
*/
|
|
@@ -208,7 +208,7 @@ const $ = class extends j {
|
|
|
208
208
|
* Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or
|
|
209
209
|
* filters, filter might not be necessary.
|
|
210
210
|
*/
|
|
211
|
-
m(this,
|
|
211
|
+
m(this, N, null);
|
|
212
212
|
/**
|
|
213
213
|
* This is where we store filtered frames from each previously processed packet.
|
|
214
214
|
* We keep these in chronological order. We hang on to them for two reasons:
|
|
@@ -221,7 +221,7 @@ const $ = class extends j {
|
|
|
221
221
|
* This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We
|
|
222
222
|
* do this ensure we don't skip any frames.
|
|
223
223
|
*/
|
|
224
|
-
m(this,
|
|
224
|
+
m(this, _, []);
|
|
225
225
|
/**
|
|
226
226
|
* This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do
|
|
227
227
|
* this ensure we don't skip any frames.
|
|
@@ -235,7 +235,7 @@ const $ = class extends j {
|
|
|
235
235
|
/**
|
|
236
236
|
* The number of threads to use for decoding
|
|
237
237
|
*/
|
|
238
|
-
m(this,
|
|
238
|
+
m(this, S, 8);
|
|
239
239
|
/**
|
|
240
240
|
* The index of the video stream in the demuxer
|
|
241
241
|
*/
|
|
@@ -256,31 +256,31 @@ const $ = class extends j {
|
|
|
256
256
|
* Use and await this method to generate an extractor.
|
|
257
257
|
*/
|
|
258
258
|
static async create(t) {
|
|
259
|
-
const
|
|
260
|
-
return await
|
|
259
|
+
const s = new $();
|
|
260
|
+
return await s.init(t), s;
|
|
261
261
|
}
|
|
262
262
|
async init({
|
|
263
263
|
inputFileOrUrl: t,
|
|
264
|
-
threadCount:
|
|
264
|
+
threadCount: s = 8,
|
|
265
265
|
outputPixelFormat: r = "rgba"
|
|
266
266
|
}) {
|
|
267
|
-
if (o(this,
|
|
267
|
+
if (o(this, S, s), t.startsWith("http")) {
|
|
268
268
|
const n = new G(t);
|
|
269
269
|
await n.download(), t = n.filepath;
|
|
270
270
|
}
|
|
271
|
-
if (t.startsWith("file:") || (t = "file:" + t), o(this, c, await R.demuxer(t)), o(this, u, e(this, c).streams.findIndex((n) => n.codecpar.codec_type ===
|
|
272
|
-
throw new Error(`File has no ${
|
|
271
|
+
if (t.startsWith("file:") || (t = "file:" + t), o(this, c, await R.demuxer(t)), o(this, u, e(this, c).streams.findIndex((n) => n.codecpar.codec_type === I)), e(this, u) === -1)
|
|
272
|
+
throw new Error(`File has no ${I} stream!`);
|
|
273
273
|
let h = "rgba";
|
|
274
|
-
const
|
|
275
|
-
r === "original" && w !== "vp8" && w !== "vp9" && (h =
|
|
274
|
+
const d = e(this, c).streams[e(this, u)].codecpar.format, w = e(this, c).streams[e(this, u)].codecpar.name;
|
|
275
|
+
r === "original" && w !== "vp8" && w !== "vp9" && (h = d), o(this, N, await j({
|
|
276
276
|
stream: e(this, c).streams[e(this, u)],
|
|
277
277
|
outputPixelFormat: h
|
|
278
278
|
}));
|
|
279
279
|
}
|
|
280
280
|
get duration() {
|
|
281
|
-
return Math.max(...e(this, c).streams.map((
|
|
282
|
-
const r =
|
|
283
|
-
return
|
|
281
|
+
return Math.max(...e(this, c).streams.filter((s) => s.codecpar.codec_type === I || s.codecpar.codec_type === K).map((s) => {
|
|
282
|
+
const r = s.time_base;
|
|
283
|
+
return s.duration * r[0] / r[1];
|
|
284
284
|
})) || this.ptsToTime(e(this, c).duration) / 1e3;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
@@ -300,16 +300,16 @@ const $ = class extends j {
|
|
|
300
300
|
* @param targetTime
|
|
301
301
|
*/
|
|
302
302
|
async getFrameAtTime(t) {
|
|
303
|
-
const
|
|
304
|
-
return this._getFrameAtPts(
|
|
303
|
+
const s = Math.round(this._timeToPTS(t));
|
|
304
|
+
return this._getFrameAtPts(s);
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* Get imageData for a given time in seconds
|
|
308
308
|
* @param targetTime
|
|
309
309
|
*/
|
|
310
|
-
async getImageDataAtTime(t,
|
|
310
|
+
async getImageDataAtTime(t, s) {
|
|
311
311
|
const r = Math.round(this._timeToPTS(t)), h = await this._getFrameAtPts(r);
|
|
312
|
-
return h ? (
|
|
312
|
+
return h ? (s && $._setFrameDataToRGBABufferTarget(h, s), {
|
|
313
313
|
width: h.width,
|
|
314
314
|
height: h.height,
|
|
315
315
|
frame: h
|
|
@@ -319,15 +319,15 @@ const $ = class extends j {
|
|
|
319
319
|
* Get the presentation timestamp (PTS) for a given time in seconds
|
|
320
320
|
*/
|
|
321
321
|
_timeToPTS(t) {
|
|
322
|
-
const
|
|
323
|
-
return t *
|
|
322
|
+
const s = e(this, c).streams[e(this, u)].time_base;
|
|
323
|
+
return t * s[1] / s[0];
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* Get the time in seconds from a given presentation timestamp (PTS)
|
|
327
327
|
*/
|
|
328
328
|
ptsToTime(t) {
|
|
329
|
-
const
|
|
330
|
-
return t *
|
|
329
|
+
const s = e(this, c).streams[e(this, u)].time_base;
|
|
330
|
+
return t * s[0] / s[1];
|
|
331
331
|
}
|
|
332
332
|
get packetReadCount() {
|
|
333
333
|
return e(this, b);
|
|
@@ -339,42 +339,42 @@ const $ = class extends j {
|
|
|
339
339
|
* the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read
|
|
340
340
|
* additional packets and find a frame that is closer to the targetPTS.
|
|
341
341
|
*/
|
|
342
|
-
async _getFrameAtPts(t,
|
|
342
|
+
async _getFrameAtPts(t, s = 0) {
|
|
343
343
|
o(this, b, 0);
|
|
344
|
-
const r = 3, h = e(this, g).flat().some((
|
|
344
|
+
const r = 3, h = e(this, g).flat().some((l) => this.ptsToTime(Math.abs(t - l.pts)) < r);
|
|
345
345
|
(e(this, v) === null || e(this, v) > t || !h) && (await e(this, c).seek({
|
|
346
346
|
stream_index: 0,
|
|
347
347
|
// even though we specify the stream index, it still seeks all streams
|
|
348
|
-
timestamp: t +
|
|
348
|
+
timestamp: t + s,
|
|
349
349
|
any: !1
|
|
350
|
-
}), await
|
|
351
|
-
let
|
|
350
|
+
}), await V(this, C, q).call(this), o(this, T, null), o(this, _, []), o(this, v, t), o(this, g, []));
|
|
351
|
+
let d = null, w = -1, n = null;
|
|
352
352
|
if (e(this, g).length > 0) {
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
const f = e(this, g).flat().find((
|
|
356
|
-
if (w =
|
|
353
|
+
const l = e(this, g).flat().find((f) => f.pts <= t);
|
|
354
|
+
if (l) {
|
|
355
|
+
const f = e(this, g).flat().find((y) => y.pts > l.pts);
|
|
356
|
+
if (w = l.pts, n = l, f && f.pts > t || w === t)
|
|
357
357
|
return o(this, v, t), n;
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
for (!e(this, T) && e(this,
|
|
361
|
-
if (e(this,
|
|
362
|
-
|
|
363
|
-
const f = e(this, b) === 1 &&
|
|
360
|
+
for (!e(this, T) && e(this, _).length === 0 && ({ packet: F(this, T)._, frames: F(this, _)._ } = await this._getNextPacketAndDecodeFrames(), F(this, b)._++); (e(this, T) || e(this, _).length !== 0) && w < t; ) {
|
|
361
|
+
if (e(this, _).length !== 0) {
|
|
362
|
+
d = (await e(this, N).filter([{ name: "in0:v", frames: e(this, _) }])).flatMap((y) => y.frames);
|
|
363
|
+
const f = e(this, b) === 1 && d[0].pts > t ? d[0] : d.reverse().find((y) => y.pts <= t);
|
|
364
364
|
if (!f)
|
|
365
365
|
return n;
|
|
366
|
-
if (e(this, g).unshift(
|
|
366
|
+
if (e(this, g).unshift(d), e(this, g).length > 2 && e(this, g).pop(), w = f == null ? void 0 : f.pts, !n || w <= t)
|
|
367
367
|
o(this, v, t), n = f;
|
|
368
368
|
else
|
|
369
369
|
break;
|
|
370
370
|
}
|
|
371
|
-
({ packet: F(this, T)._, frames: F(this,
|
|
371
|
+
({ packet: F(this, T)._, frames: F(this, _)._ } = await this._getNextPacketAndDecodeFrames()), F(this, b)._++;
|
|
372
372
|
}
|
|
373
373
|
if (!n) {
|
|
374
|
-
if (
|
|
374
|
+
if (Z < e(this, k))
|
|
375
375
|
throw Error("No matching frame found");
|
|
376
|
-
const
|
|
377
|
-
F(this, k)._++, n = await this._getFrameAtPts(t,
|
|
376
|
+
const l = 0.1, f = this._timeToPTS(l);
|
|
377
|
+
F(this, k)._++, n = await this._getFrameAtPts(t, s - f), n && o(this, k, 0);
|
|
378
378
|
}
|
|
379
379
|
return n;
|
|
380
380
|
}
|
|
@@ -385,10 +385,10 @@ const $ = class extends j {
|
|
|
385
385
|
*/
|
|
386
386
|
async _getNextPacketAndDecodeFrames() {
|
|
387
387
|
const t = await this._getNextVideoStreamPacket();
|
|
388
|
-
let
|
|
389
|
-
t !== null && e(this, p) ?
|
|
388
|
+
let s = null;
|
|
389
|
+
t !== null && e(this, p) ? s = await e(this, p).decode(t) : e(this, p) && (s = await e(this, p).flush(), o(this, p, null));
|
|
390
390
|
let r = [];
|
|
391
|
-
return
|
|
391
|
+
return s && s.frames.length !== 0 && (r = s.frames), { packet: t, frames: r };
|
|
392
392
|
}
|
|
393
393
|
async _getNextVideoStreamPacket() {
|
|
394
394
|
let t = await e(this, c).read();
|
|
@@ -397,67 +397,67 @@ const $ = class extends j {
|
|
|
397
397
|
return null;
|
|
398
398
|
return t;
|
|
399
399
|
}
|
|
400
|
-
static _setFrameDataToRGBABufferTarget(t,
|
|
401
|
-
const r = t.linesize, h = t.data[0],
|
|
400
|
+
static _setFrameDataToRGBABufferTarget(t, s) {
|
|
401
|
+
const r = t.linesize, h = t.data[0], d = t.width, w = t.height;
|
|
402
402
|
for (let n = 0; n < w; n++) {
|
|
403
|
-
const
|
|
404
|
-
|
|
403
|
+
const l = n * r, f = l + d * L, y = h.subarray(l, f), M = n * d * L;
|
|
404
|
+
s.set(y, M);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
async dispose() {
|
|
408
|
-
e(this, p) && (await e(this, p).flush(), o(this, p, null)), e(this, c).forceClose(), o(this,
|
|
408
|
+
e(this, p) && (await e(this, p).flush(), o(this, p, null)), e(this, c).forceClose(), o(this, N, null), o(this, g, void 0), o(this, _, []), o(this, T, null), o(this, v, null), o(this, u, 0);
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
411
|
let W = $;
|
|
412
|
-
c = new WeakMap(), p = new WeakMap(),
|
|
413
|
-
e(this, p) && (await e(this, p).flush(), o(this, p, null)), o(this, p,
|
|
412
|
+
c = new WeakMap(), p = new WeakMap(), N = new WeakMap(), g = new WeakMap(), _ = new WeakMap(), T = new WeakMap(), v = new WeakMap(), S = new WeakMap(), u = new WeakMap(), b = new WeakMap(), k = new WeakMap(), C = new WeakSet(), q = async function() {
|
|
413
|
+
e(this, p) && (await e(this, p).flush(), o(this, p, null)), o(this, p, Y({
|
|
414
414
|
demuxer: e(this, c),
|
|
415
415
|
streamIndex: e(this, u),
|
|
416
|
-
threadCount: e(this,
|
|
416
|
+
threadCount: e(this, S)
|
|
417
417
|
}));
|
|
418
418
|
};
|
|
419
|
-
var
|
|
420
|
-
class
|
|
419
|
+
var A;
|
|
420
|
+
class st {
|
|
421
421
|
constructor() {
|
|
422
|
-
m(this,
|
|
422
|
+
m(this, A, /* @__PURE__ */ new Map());
|
|
423
423
|
}
|
|
424
|
-
get(
|
|
424
|
+
get(i) {
|
|
425
425
|
const t = this;
|
|
426
|
-
let
|
|
426
|
+
let s;
|
|
427
427
|
return {
|
|
428
|
-
url:
|
|
428
|
+
url: i,
|
|
429
429
|
get filepath() {
|
|
430
|
-
return
|
|
430
|
+
return s;
|
|
431
431
|
},
|
|
432
432
|
async download() {
|
|
433
|
-
let r = e(t,
|
|
433
|
+
let r = e(t, A).get(i);
|
|
434
434
|
if (r)
|
|
435
435
|
r.refCount += 1, r.downloadPromise && await r.downloadPromise;
|
|
436
436
|
else {
|
|
437
|
-
const h = new G(
|
|
437
|
+
const h = new G(i), d = h.download();
|
|
438
438
|
r = {
|
|
439
439
|
downloader: h,
|
|
440
440
|
refCount: 1,
|
|
441
|
-
downloadPromise:
|
|
442
|
-
}, e(t,
|
|
441
|
+
downloadPromise: d
|
|
442
|
+
}, e(t, A).set(i, r);
|
|
443
443
|
try {
|
|
444
|
-
await
|
|
444
|
+
await d;
|
|
445
445
|
} finally {
|
|
446
446
|
r.downloadPromise = void 0;
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
|
|
449
|
+
s = e(t, A).get(i).downloader.filepath;
|
|
450
450
|
},
|
|
451
451
|
destroy() {
|
|
452
|
-
const r = e(t,
|
|
453
|
-
r && (r.refCount -= 1, r.refCount <= 0 && (r.downloader.clear(), e(t,
|
|
452
|
+
const r = e(t, A).get(i);
|
|
453
|
+
r && (r.refCount -= 1, r.refCount <= 0 && (r.downloader.clear(), e(t, A).delete(i)), s = void 0);
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
|
|
458
|
+
A = new WeakMap();
|
|
459
459
|
export {
|
|
460
460
|
W as BeamcoderExtractor,
|
|
461
|
-
|
|
461
|
+
st as CachedVideoDownloader
|
|
462
462
|
};
|
|
463
463
|
//# sourceMappingURL=framefusion.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framefusion.es.js","sources":["../src/BaseExtractor.ts","../src/DownloadVideoURL.ts","../src/backends/beamcoder.ts","../src/cachedVideoDownloader.ts"],"sourcesContent":["import type {\n ExtractorArgs,\n Frame,\n Extractor\n} from '../framefusion';\nimport type { ImageData } from './types';\n\n\nexport class BaseExtractor implements Extractor {\n static async create(args: ExtractorArgs): Promise<Extractor> {\n throw new Error('Not implemented');\n }\n\n async init({\n inputFileOrUrl,\n outputFile,\n threadCount = 8,\n endTime,\n interpolateFps,\n interpolateMode,\n }: ExtractorArgs): Promise<void> {\n throw new Error('Not implemented');\n }\n\n get duration(): number {\n throw new Error('Not implemented');\n }\n\n get width(): number {\n throw new Error('Not implemented');\n }\n\n get height(): number {\n throw new Error('Not implemented');\n }\n\n async seekToPTS(targetPts: number) {\n throw new Error('Not implemented');\n }\n\n async getFrameAtTime(targetTime: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async getImageDataAtTime(targetTime: number): Promise<ImageData> {\n throw new Error('Not implemented');\n }\n\n async getFrameAtPts(targetPts: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async seekToTime(targetTime: number) {\n throw new Error('Not implemented');\n }\n\n /**\n * Convert a PTS (based on timebase) to PTS (in seconds)\n */\n ptsToTime(pts: number) {\n throw new Error('Not implemented');\n }\n\n async readFrames({\n onFrameAvailable,\n flush = true,\n }: {\n /**\n * Return true if we need to read more frames.\n */\n onFrameAvailable?: (frame: Frame) => Promise<boolean> | boolean;\n flush?: boolean;\n } = {\n flush: true,\n onFrameAvailable: () => true,\n }) {\n throw new Error('Not implemented');\n }\n\n async dispose() {\n throw new Error('Not implemented');\n }\n}\n","import path from 'path';\nimport type { ClientRequest } from 'http';\nimport tmp from 'tmp';\nimport fs from 'fs-extra';\n\n/**\n * Downloads a video file from a given URL as a temporary file. When the object is cleared, the temporary file is\n * deleted.\n */\nexport class DownloadVideoURL {\n #url: string | undefined;\n #httpRequest: ClientRequest | undefined = undefined;\n #filepath: string;\n #tmpObj: tmp.FileResult | undefined = undefined;\n\n constructor(url: string) {\n this.#url = url;\n\n const extension = path.extname(url);\n this.#tmpObj = tmp.fileSync({ postfix: extension });\n this.#filepath = this.#tmpObj.name;\n }\n\n /**\n * returns the filepath of the downloaded file. If the file has not been downloaded yet, it will be undefined\n */\n get filepath() {\n return this.#filepath;\n }\n\n /**\n * Downloads the file from the given URL. The file will be downloaded to a temporary file.\n */\n async download() {\n const source = this.#url;\n\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch ${source}, status: ${response.status}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n if (!contentType || !contentType.includes('video')) {\n throw new Error(\n `Source ${source}, returned unsupported content type ${contentType}`\n );\n }\n\n const writeStream = fs.createWriteStream(this.#tmpObj.name);\n const readableStream = response.body;\n\n if (!readableStream) {\n throw new Error(`Response body is null for ${source}`);\n }\n\n const reader = readableStream.getReader();\n\n return new Promise<void>((resolve, reject) => {\n const pump = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n writeStream.end(() => {\n this.#filepath = this.#tmpObj.name;\n resolve();\n });\n return;\n }\n const buffer = Buffer.from(value);\n if (!writeStream.write(buffer)) {\n // Wait for 'drain' before continuing\n writeStream.once('drain', pump);\n }\n else {\n pump();\n }\n }).catch(reject);\n };\n\n writeStream.on('error', reject);\n pump();\n });\n }\n\n clear() {\n if (this.#tmpObj) this.#tmpObj.removeCallback();\n if (this.#url) this.#url = undefined;\n if (this.#httpRequest) this.#httpRequest = null;\n if (this.#filepath) this.#filepath = undefined;\n }\n}\n","import type {\n Packet,\n Demuxer,\n Decoder,\n Filterer,\n Frame\n} from '@lumen5/beamcoder';\nimport beamcoder from '@lumen5/beamcoder';\nimport type { ImageData } from '../types';\nimport { BaseExtractor } from '../BaseExtractor';\nimport type { Extractor, ExtractorArgs, InterpolateMode } from '../../framefusion';\nimport { DownloadVideoURL } from '../DownloadVideoURL';\n\nconst VERBOSE = false;\n\n/**\n * RGBA format need one byte for every components: r, g, b and a\n */\nexport const RGBA_PIXEL_SIZE = 4;\n\nconst createDecoder = ({\n demuxer,\n streamIndex,\n threadCount,\n}: {\n demuxer: Demuxer;\n streamIndex: number;\n threadCount: number;\n}): Decoder => {\n const commonParams = {\n width: demuxer.streams[streamIndex].codecpar.width,\n height: demuxer.streams[streamIndex].codecpar.height,\n pix_fmt: demuxer.streams[streamIndex].codecpar.format,\n thread_count: threadCount,\n };\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp8') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx',\n });\n }\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp9') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx-vp9',\n });\n }\n\n return beamcoder.decoder({\n ...commonParams,\n demuxer: demuxer,\n stream_index: streamIndex,\n });\n};\n\n/**\n * A filter to convert between color spaces.\n * An example would be YUV to RGB, for mp4 to png conversion.\n */\nconst createFilter = async({\n stream,\n outputPixelFormat,\n interpolateFps,\n interpolateMode = 'fast',\n}: {\n stream: beamcoder.Stream;\n outputPixelFormat: string;\n interpolateFps?: number;\n interpolateMode?: InterpolateMode;\n}): Promise<beamcoder.Filterer> => {\n if (!stream.codecpar.format) {\n return null;\n }\n\n let filterSpec = [`[in0:v]format=${stream.codecpar.format}`];\n\n if (interpolateFps) {\n if (interpolateMode === 'high-quality') {\n filterSpec = [...filterSpec, `minterpolate=fps=${interpolateFps}`];\n }\n else if (interpolateMode === 'fast') {\n filterSpec = [...filterSpec, `fps=${interpolateFps}`];\n }\n else {\n throw new Error(`Unexpected interpolation mode: ${interpolateMode}`);\n }\n }\n\n const filterSpecStr = filterSpec.join(', ') + '[out0:v]';\n\n VERBOSE && console.log(`filterSpec: ${filterSpecStr}`);\n\n return beamcoder.filterer({\n filterType: 'video',\n inputParams: [\n {\n name: 'in0:v',\n width: stream.codecpar.width,\n height: stream.codecpar.height,\n pixelFormat: stream.codecpar.format,\n timeBase: stream.time_base,\n pixelAspect: stream.sample_aspect_ratio,\n },\n ],\n outputParams: [\n {\n name: 'out0:v',\n pixelFormat: outputPixelFormat,\n },\n ],\n filterSpec: filterSpecStr,\n });\n};\n\nconst STREAM_TYPE_VIDEO = 'video';\nconst MAX_RECURSION = 5;\n\n/**\n * A simple extractor that uses beamcoder to extract frames from a video file.\n */\nexport class BeamcoderExtractor extends BaseExtractor implements Extractor {\n /**\n * The demuxer reads the file and outputs packet streams\n */\n #demuxer: Demuxer = null;\n\n /**\n * The decoder reads packets and can output raw frame data\n */\n #decoder: Decoder = null;\n\n /**\n * Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or\n * filters, filter might not be necessary.\n */\n #filterer: Filterer = null;\n\n /**\n * This is where we store filtered frames from each previously processed packet.\n * We keep these in chronological order. We hang on to them for two reasons:\n * 1. so we can return them if we get a request for the same time again\n * 2. so we can return frames close the end of the stream. When such a frame is requested we have to flush (destroy)\n * the encoder to get the last few frames. This avoids having to re-create an encoder.\n */\n #filteredFramesPacket: undefined[] | Array<Array<Frame>> = [];\n\n /**\n * This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We\n * do this ensure we don't skip any frames.\n */\n #frames = [];\n\n /**\n * This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do\n * this ensure we don't skip any frames.\n */\n #packet: null | Packet = null;\n\n /**\n * The last target presentation timestamp (PTS) we requested. If we never requested a time(stamp) then this\n * value is null\n */\n #previousTargetPTS: null | number = null;\n\n /**\n * The number of threads to use for decoding\n */\n #threadCount = 8;\n\n /**\n * The index of the video stream in the demuxer\n */\n #streamIndex = 0;\n\n /**\n * The number of packets we've read from the demuxer to complete the frame query\n * @private\n */\n #packetReadCount = 0;\n\n /**\n * The number of times we've recursively read packets from the demuxer to complete the frame query\n * @private\n */\n #recursiveReadCount = 0;\n\n /**\n * Encoder/Decoder construction is async, so it can't be put in a regular constructor.\n * Use and await this method to generate an extractor.\n */\n static async create(args: ExtractorArgs): Promise<BeamcoderExtractor> {\n const extractor = new BeamcoderExtractor();\n await extractor.init(args);\n return extractor;\n }\n\n async init({\n inputFileOrUrl,\n threadCount = 8,\n outputPixelFormat = 'rgba',\n }: ExtractorArgs): Promise<void> {\n this.#threadCount = threadCount;\n VERBOSE && console.log('inputFileOrUrl before pre-processing: ', inputFileOrUrl);\n if (inputFileOrUrl.startsWith('http')) {\n VERBOSE && console.log('downloading url', inputFileOrUrl);\n const downloadUrl = new DownloadVideoURL(inputFileOrUrl);\n await downloadUrl.download();\n inputFileOrUrl = downloadUrl.filepath;\n VERBOSE && console.log('finished downloading');\n }\n // Assume file url at this point\n if (!inputFileOrUrl.startsWith('file:')) {\n inputFileOrUrl = 'file:' + inputFileOrUrl;\n }\n VERBOSE && console.log('inputFileOrUrl after pre-processing: ', inputFileOrUrl);\n VERBOSE && console.log('beamcoder.protocols(): ', JSON.stringify(beamcoder.protocols()));\n this.#demuxer = await beamcoder.demuxer(inputFileOrUrl);\n VERBOSE && console.log('demuxer creation succeeded.');\n this.#streamIndex = this.#demuxer.streams.findIndex(stream => stream.codecpar.codec_type === STREAM_TYPE_VIDEO);\n\n if (this.#streamIndex === -1) {\n throw new Error(`File has no ${STREAM_TYPE_VIDEO} stream!`);\n }\n let pixelFormat = 'rgba';\n const origianlPixelFormat = this.#demuxer.streams[this.#streamIndex].codecpar.format;\n const codecName = this.#demuxer.streams[this.#streamIndex].codecpar.name;\n // vp8 and vp9 this.#demuxer.streams[this.#streamIndex].codecpar.format is 'yuv420p', but the decoder outputs yuva420p\n if (outputPixelFormat === 'original' && codecName !== 'vp8' && codecName !== 'vp9') {\n pixelFormat = origianlPixelFormat;\n }\n this.#filterer = await createFilter({\n stream: this.#demuxer.streams[this.#streamIndex],\n outputPixelFormat: pixelFormat,\n });\n }\n\n async #createDecoder() {\n // It's possible that we need to create decoder multiple times during the lifecycle of this extractor so we\n // need to make sure we destroy the old one first if it exists\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#decoder = createDecoder({\n demuxer: this.#demuxer as Demuxer,\n streamIndex: this.#streamIndex,\n threadCount: this.#threadCount,\n });\n }\n\n get duration(): number {\n const maxStreamsDuration = Math.max(...this.#demuxer.streams\n .map(s => {\n const time_base = s.time_base;\n return s.duration * time_base[0] / time_base[1];\n }));\n // MP4 duration is defined as the longest stream duration\n // Webm stores it in Segment.Info.Duration\n return maxStreamsDuration || (this.ptsToTime(this.#demuxer.duration) / 1000);\n }\n\n /**\n * Width in pixels\n */\n get width(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.width;\n }\n\n /**\n * Height in pixels\n */\n get height(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.height;\n }\n\n /**\n * Get the beamcoder Frame for a given time in seconds\n * @param targetTime\n */\n async getFrameAtTime(targetTime: number): Promise<beamcoder.Frame> {\n VERBOSE && console.log(`getFrameAtTime time(s)=${targetTime}`);\n const targetPts = Math.round(this._timeToPTS(targetTime));\n return this._getFrameAtPts(targetPts);\n }\n\n /**\n * Get imageData for a given time in seconds\n * @param targetTime\n */\n async getImageDataAtTime(targetTime: number, rgbaBufferTarget?: Uint8ClampedArray): Promise<ImageData> {\n const targetPts = Math.round(this._timeToPTS(targetTime));\n VERBOSE && console.log('targetTime', targetTime, '-> targetPts', targetPts);\n const frame = await this._getFrameAtPts(targetPts);\n if (!frame) {\n VERBOSE && console.log('no frame found');\n return null;\n }\n\n if (rgbaBufferTarget) {\n BeamcoderExtractor._setFrameDataToRGBABufferTarget(frame, rgbaBufferTarget);\n }\n\n return {\n width: frame.width,\n height: frame.height,\n frame,\n };\n }\n\n /**\n * Get the presentation timestamp (PTS) for a given time in seconds\n */\n _timeToPTS(time: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return time * time_base[1] / time_base[0];\n }\n\n /**\n * Get the time in seconds from a given presentation timestamp (PTS)\n */\n ptsToTime(pts: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return pts * time_base[0] / time_base[1];\n }\n\n get packetReadCount() {\n return this.#packetReadCount;\n }\n\n /**\n * Get the frame at the given presentation timestamp (PTS)\n * @param targetPTS - the target presentation timestamp (PTS) we want to retrieve\n * @param SeekPTSOffset - the offset to use when seeking to the targetPTS. This is used when we have trouble finding\n * the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read\n * additional packets and find a frame that is closer to the targetPTS.\n */\n async _getFrameAtPts(targetPTS: number, SeekPTSOffset = 0): Promise<beamcoder.Frame> {\n VERBOSE && console.log('_getFrameAtPts', targetPTS, 'seekPTSOffset', SeekPTSOffset, 'duration', this.duration);\n this.#packetReadCount = 0;\n\n // seek and create a decoder when retrieving a frame for the first time or when seeking backwards\n // we have to create a new decoder when seeking backwards as the decoder can only process frames in\n // chronological order.\n // RE_SEEK_DELTA: sometimes, we are looking for a frame so far ahead that it's better to drop everything and seek.\n // Example: when we got a frame a 0 and request a frame at t = 30s just after, we don't want to start reading all packets\n // until 30s.\n const RE_SEEK_THRESHOLD = 3; // 3 seconds - typically we have keyframes at shorter intervals\n const hasFrameWithinThreshold = this.#filteredFramesPacket.flat().some(frame => {\n return this.ptsToTime(Math.abs(targetPTS - (frame as Frame).pts)) < RE_SEEK_THRESHOLD;\n });\n VERBOSE && console.log('hasPreviousTargetPTS:', this.#previousTargetPTS === null, ', targetPTS is smaller:', this.#previousTargetPTS > targetPTS, ', has frame within threshold:', hasFrameWithinThreshold);\n if (this.#previousTargetPTS === null || this.#previousTargetPTS > targetPTS || !hasFrameWithinThreshold) {\n VERBOSE && console.log(`Seeking to ${targetPTS + SeekPTSOffset}`);\n\n await this.#demuxer.seek({\n stream_index: 0, // even though we specify the stream index, it still seeks all streams\n timestamp: targetPTS + SeekPTSOffset,\n any: false,\n });\n await this.#createDecoder();\n this.#packet = null;\n this.#frames = [];\n this.#previousTargetPTS = targetPTS;\n this.#filteredFramesPacket = [];\n }\n\n let filteredFrames = null;\n let closestFramePTS = -1;\n let outputFrame = null;\n\n // If we have previously filtered frames, get the frame closest to our targetPTS\n if (this.#filteredFramesPacket.length > 0) {\n const closestFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts <= targetPTS) as Frame;\n\n if (closestFrame) {\n const nextFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts > closestFrame.pts) as Frame;\n\n VERBOSE && console.log('returning previously filtered frame with pts', (closestFrame as Frame).pts);\n closestFramePTS = (closestFrame as Frame).pts;\n outputFrame = closestFrame;\n\n if ((nextFrame && nextFrame.pts > targetPTS) || (closestFramePTS === targetPTS)) {\n // We have a next frame, so we know the frame being displayed at targetPTS is the previous one,\n // which corresponds to outputFrame.\n this.#previousTargetPTS = targetPTS;\n return outputFrame;\n }\n }\n }\n\n // This is the first time we're decoding frames. Get the first packet and decode it.\n if (!this.#packet && this.#frames.length === 0) {\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n this.#packetReadCount++;\n }\n // Read packets until we have a frame which is closest to targetPTS\n while ((this.#packet || this.#frames.length !== 0) && closestFramePTS < targetPTS) {\n VERBOSE && console.log('packet si:', this.#packet?.stream_index, 'pts:', this.#packet?.pts, 'frames:', this.#frames?.length);\n VERBOSE && console.log('frames', this.#frames?.length, 'frames.pts:', JSON.stringify(this.#frames?.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // packet contains frames\n if (this.#frames.length !== 0) {\n // filter the frames\n const filteredResult = await this.#filterer.filter([{ name: 'in0:v', frames: this.#frames }]);\n filteredFrames = filteredResult.flatMap(r => r.frames);\n VERBOSE && console.log('filteredFrames', filteredFrames.length, 'filteredFrames.pts:', JSON.stringify(filteredFrames.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // get the closest frame to our target presentation timestamp (PTS)\n // Beamcoder returns decoded packet frames as follows: [1000, 2000, 3000, 4000]\n // If we're looking for a frame at 0, we want to return the frame at 1000\n // If we're looking for a frame at 2500, we want to return the frame at 2000\n const closestFrame = (this.#packetReadCount === 1 && filteredFrames[0].pts > targetPTS)\n ? filteredFrames[0]\n : filteredFrames.reverse().find(f => f.pts <= targetPTS);\n\n // The packet contains frames, but all of them have PTS larger than our a targetPTS (we looked too far)\n if (!closestFrame) {\n return outputFrame;\n }\n\n // store the filtered packet frames for later reuse\n this.#filteredFramesPacket.unshift(filteredFrames);\n if (this.#filteredFramesPacket.length > 2) {\n this.#filteredFramesPacket.pop();\n }\n\n closestFramePTS = closestFrame?.pts;\n VERBOSE && console.log('closestFramePTS', closestFramePTS, 'targetPTS', targetPTS);\n if (!outputFrame || closestFramePTS <= targetPTS) {\n VERBOSE && console.log('assigning outputFrame', closestFrame?.pts);\n this.#previousTargetPTS = targetPTS;\n outputFrame = closestFrame;\n }\n else {\n // break out of the loop if we've found the closest frame (and ensure we don't move to the next\n // packet by calling _getNextPacketAndDecodeFrames again) as this risks us getting a frame that is\n // after our targetPTS\n VERBOSE && console.log('breaking');\n break;\n }\n }\n // get the next packet and frames\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n\n // keep track of how many packets we've read\n this.#packetReadCount++;\n }\n\n // we read through all the available packets and frames, but we still don't have a frame. This can happen\n // when our targetPTS is to close to the end of the video. In this case, we'll try to seek further away from\n // the end of the video and try again. We've set up a MAX_RECURSION to prevent an infinite loop.\n if (!outputFrame) {\n if (MAX_RECURSION < this.#recursiveReadCount) {\n throw Error('No matching frame found');\n }\n const TIME_OFFSET = 0.1; // time offset in seconds\n const PTSOffset = this._timeToPTS(TIME_OFFSET);\n this.#recursiveReadCount++;\n outputFrame = await this._getFrameAtPts(targetPTS, SeekPTSOffset - PTSOffset);\n if (outputFrame) {\n this.#recursiveReadCount = 0;\n }\n }\n VERBOSE && console.log('read', this.packetReadCount, 'packets');\n\n return outputFrame;\n }\n\n /**\n * Get the next packet from the video stream and decode it into frames. Each frame has a presentation time stamp\n * (PTS). If we've reached the end of the stream and no more packets are available, we'll extract the last frames\n * from the decoder and destroy it.\n */\n async _getNextPacketAndDecodeFrames() {\n const packet = await this._getNextVideoStreamPacket();\n VERBOSE && console.log('packet pts:', packet?.pts);\n\n // extract frames from the packet\n let decodedFrames = null;\n if (packet !== null && this.#decoder) {\n decodedFrames = await this.#decoder.decode(packet as Packet);\n VERBOSE && console.log('decodedFrames', decodedFrames.frames.length, decodedFrames.frames.map(f => f.pts));\n }\n // we've reached the end of the stream\n else {\n if (this.#decoder) {\n VERBOSE && console.log('getting the last frames from the decoder');\n // flush the decoder -- this will return the last frames and destroy the decoder\n decodedFrames = await this.#decoder.flush();\n this.#decoder = null;\n }\n else {\n // we don't have a decoder, so we can't decode any more frames\n VERBOSE && console.log('no more frames to decode');\n }\n }\n\n let frames = [];\n if (decodedFrames && decodedFrames.frames.length !== 0) {\n frames = decodedFrames.frames;\n }\n VERBOSE && console.log(`returning ${frames.length} decoded frames`);\n\n return { packet, frames };\n }\n\n async _getNextVideoStreamPacket(): Promise<null | Packet> {\n VERBOSE && console.log('_getNextVideoStreamPacket');\n\n let packet = await this.#demuxer.read();\n while (packet && packet.stream_index !== this.#streamIndex) {\n packet = await this.#demuxer.read();\n if (packet === null) {\n VERBOSE && console.log('no more packets');\n return null;\n }\n }\n VERBOSE && console.log('returning packet', !!packet, 'pts', packet?.pts, 'si', packet?.stream_index);\n return packet as Packet;\n }\n\n static _setFrameDataToRGBABufferTarget(frame: beamcoder.Frame, rgbaBufferTarget: Uint8ClampedArray) {\n const sourceLineSize = frame.linesize as unknown as number;\n // frame.data can contain multiple \"planes\" in other colorspaces, but in rgba, there is just one \"plane\", so\n // our data is in frame.data[0]\n const pixels = frame.data[0] as Uint8Array;\n const width = frame.width;\n const height = frame.height;\n\n // libav creates larger buffers because it makes their internal code simpler.\n // we have to trim a part at the right of each pixel row.\n\n for (let i = 0; i < height; i++) {\n const sourceStart = i * sourceLineSize;\n const sourceEnd = sourceStart + width * RGBA_PIXEL_SIZE;\n const sourceData = pixels.subarray(sourceStart, sourceEnd);\n const targetOffset = i * width * RGBA_PIXEL_SIZE;\n rgbaBufferTarget.set(sourceData, targetOffset);\n }\n }\n\n async dispose() {\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#demuxer.forceClose();\n this.#filterer = null;\n this.#filteredFramesPacket = undefined;\n this.#frames = [];\n this.#packet = null;\n this.#previousTargetPTS = null;\n this.#streamIndex = 0;\n }\n}\n","import { DownloadVideoURL } from './DownloadVideoURL';\n\ninterface CachedResource {\n url: string;\n filepath: string | undefined;\n download(): Promise<void>;\n destroy(): void;\n}\n\ninterface CacheEntry {\n downloader: DownloadVideoURL;\n refCount: number;\n downloadPromise?: Promise<void>;\n}\n\nexport class CachedVideoDownloader {\n #cache: Map<string, CacheEntry> = new Map();\n\n get(url: string): CachedResource {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n let filepath: string | undefined;\n\n return {\n url,\n get filepath() {\n return filepath;\n },\n\n async download() {\n let entry = self.#cache.get(url);\n\n if (entry) {\n entry.refCount += 1;\n\n // Wait for in-progress download if exists\n if (entry.downloadPromise) {\n await entry.downloadPromise;\n }\n }\n else {\n const downloader = new DownloadVideoURL(url);\n\n const promise = downloader.download();\n entry = {\n downloader,\n refCount: 1,\n downloadPromise: promise,\n };\n self.#cache.set(url, entry);\n\n try {\n await promise;\n }\n finally {\n entry.downloadPromise = undefined; // Clear after completion\n }\n }\n\n filepath = self.#cache.get(url).downloader.filepath;\n },\n\n destroy() {\n const entry = self.#cache.get(url);\n if (!entry) return;\n\n entry.refCount -= 1;\n\n if (entry.refCount <= 0) {\n entry.downloader.clear();\n self.#cache.delete(url);\n }\n\n filepath = undefined;\n },\n };\n }\n}\n"],"names":["BaseExtractor","args","inputFileOrUrl","outputFile","threadCount","endTime","interpolateFps","interpolateMode","targetPts","targetTime","pts","onFrameAvailable","flush","DownloadVideoURL","url","__privateAdd","_url","_httpRequest","_filepath","_tmpObj","__privateSet","extension","path","tmp","__privateGet","source","response","contentType","writeStream","fs","readableStream","reader","resolve","reject","pump","done","value","buffer","RGBA_PIXEL_SIZE","createDecoder","demuxer","streamIndex","commonParams","beamcoder","createFilter","stream","outputPixelFormat","filterSpec","filterSpecStr","STREAM_TYPE_VIDEO","MAX_RECURSION","_BeamcoderExtractor","_createDecoder","_demuxer","_decoder","_filterer","_filteredFramesPacket","_frames","_packet","_previousTargetPTS","_threadCount","_streamIndex","_packetReadCount","_recursiveReadCount","extractor","downloadUrl","pixelFormat","origianlPixelFormat","codecName","s","time_base","rgbaBufferTarget","frame","time","targetPTS","SeekPTSOffset","RE_SEEK_THRESHOLD","hasFrameWithinThreshold","__privateMethod","createDecoder_fn","filteredFrames","closestFramePTS","outputFrame","closestFrame","nextFrame","f","__privateWrapper","r","TIME_OFFSET","PTSOffset","packet","decodedFrames","frames","sourceLineSize","pixels","width","height","i","sourceStart","sourceEnd","sourceData","targetOffset","BeamcoderExtractor","CachedVideoDownloader","_cache","self","filepath","entry","downloader","promise"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,MAAMA,EAAmC;AAAA,EAC5C,aAAa,OAAOC,GAAyC;AACnD,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,KAAK;AAAA,IACP,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,EAAA,GAC6B;AACvB,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,WAAmB;AACb,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,QAAgB;AACV,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,SAAiB;AACX,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,UAAUC,GAAmB;AACzB,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,eAAeC,GAAoC;AAC/C,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,mBAAmBA,GAAwC;AACvD,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,cAAcD,GAAmC;AAC7C,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,WAAWC,GAAoB;AAC3B,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAUC,GAAa;AACb,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,WAAW;AAAA,IACb,kBAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,EAAA,IAOR;AAAA,IACA,OAAO;AAAA,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achedVideoDownloader.ts"],"sourcesContent":["import type {\n ExtractorArgs,\n Frame,\n Extractor\n} from '../framefusion';\nimport type { ImageData } from './types';\n\n\nexport class BaseExtractor implements Extractor {\n static async create(args: ExtractorArgs): Promise<Extractor> {\n throw new Error('Not implemented');\n }\n\n async init({\n inputFileOrUrl,\n outputFile,\n threadCount = 8,\n endTime,\n interpolateFps,\n interpolateMode,\n }: ExtractorArgs): Promise<void> {\n throw new Error('Not implemented');\n }\n\n get duration(): number {\n throw new Error('Not implemented');\n }\n\n get width(): number {\n throw new Error('Not implemented');\n }\n\n get height(): number {\n throw new Error('Not implemented');\n }\n\n async seekToPTS(targetPts: number) {\n throw new Error('Not implemented');\n }\n\n async getFrameAtTime(targetTime: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async getImageDataAtTime(targetTime: number): Promise<ImageData> {\n throw new Error('Not implemented');\n }\n\n async getFrameAtPts(targetPts: number): Promise<Frame> {\n throw new Error('Not implemented');\n }\n\n async seekToTime(targetTime: number) {\n throw new Error('Not implemented');\n }\n\n /**\n * Convert a PTS (based on timebase) to PTS (in seconds)\n */\n ptsToTime(pts: number) {\n throw new Error('Not implemented');\n }\n\n async readFrames({\n onFrameAvailable,\n flush = true,\n }: {\n /**\n * Return true if we need to read more frames.\n */\n onFrameAvailable?: (frame: Frame) => Promise<boolean> | boolean;\n flush?: boolean;\n } = {\n flush: true,\n onFrameAvailable: () => true,\n }) {\n throw new Error('Not implemented');\n }\n\n async dispose() {\n throw new Error('Not implemented');\n }\n}\n","import path from 'path';\nimport type { ClientRequest } from 'http';\nimport tmp from 'tmp';\nimport fs from 'fs-extra';\n\n/**\n * Downloads a video file from a given URL as a temporary file. When the object is cleared, the temporary file is\n * deleted.\n */\nexport class DownloadVideoURL {\n #url: string | undefined;\n #httpRequest: ClientRequest | undefined = undefined;\n #filepath: string;\n #tmpObj: tmp.FileResult | undefined = undefined;\n\n constructor(url: string) {\n this.#url = url;\n\n const extension = path.extname(url);\n this.#tmpObj = tmp.fileSync({ postfix: extension });\n this.#filepath = this.#tmpObj.name;\n }\n\n /**\n * returns the filepath of the downloaded file. If the file has not been downloaded yet, it will be undefined\n */\n get filepath() {\n return this.#filepath;\n }\n\n /**\n * Downloads the file from the given URL. The file will be downloaded to a temporary file.\n */\n async download() {\n const source = this.#url;\n\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch ${source}, status: ${response.status}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n if (!contentType || !contentType.includes('video')) {\n throw new Error(\n `Source ${source}, returned unsupported content type ${contentType}`\n );\n }\n\n const writeStream = fs.createWriteStream(this.#tmpObj.name);\n const readableStream = response.body;\n\n if (!readableStream) {\n throw new Error(`Response body is null for ${source}`);\n }\n\n const reader = readableStream.getReader();\n\n return new Promise<void>((resolve, reject) => {\n const pump = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n writeStream.end(() => {\n this.#filepath = this.#tmpObj.name;\n resolve();\n });\n return;\n }\n const buffer = Buffer.from(value);\n if (!writeStream.write(buffer)) {\n // Wait for 'drain' before continuing\n writeStream.once('drain', pump);\n }\n else {\n pump();\n }\n }).catch(reject);\n };\n\n writeStream.on('error', reject);\n pump();\n });\n }\n\n clear() {\n if (this.#tmpObj) this.#tmpObj.removeCallback();\n if (this.#url) this.#url = undefined;\n if (this.#httpRequest) this.#httpRequest = null;\n if (this.#filepath) this.#filepath = undefined;\n }\n}\n","import type {\n Packet,\n Demuxer,\n Decoder,\n Filterer,\n Frame\n} from '@lumen5/beamcoder';\nimport beamcoder from '@lumen5/beamcoder';\nimport type { ImageData } from '../types';\nimport { BaseExtractor } from '../BaseExtractor';\nimport type { Extractor, ExtractorArgs, InterpolateMode } from '../../framefusion';\nimport { DownloadVideoURL } from '../DownloadVideoURL';\n\nconst VERBOSE = false;\n\n/**\n * RGBA format need one byte for every components: r, g, b and a\n */\nexport const RGBA_PIXEL_SIZE = 4;\n\nconst createDecoder = ({\n demuxer,\n streamIndex,\n threadCount,\n}: {\n demuxer: Demuxer;\n streamIndex: number;\n threadCount: number;\n}): Decoder => {\n const commonParams = {\n width: demuxer.streams[streamIndex].codecpar.width,\n height: demuxer.streams[streamIndex].codecpar.height,\n pix_fmt: demuxer.streams[streamIndex].codecpar.format,\n thread_count: threadCount,\n };\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp8') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx',\n });\n }\n\n if (demuxer.streams[streamIndex].codecpar.name === 'vp9') {\n return beamcoder.decoder({\n ...commonParams,\n name: 'libvpx-vp9',\n });\n }\n\n return beamcoder.decoder({\n ...commonParams,\n demuxer: demuxer,\n stream_index: streamIndex,\n });\n};\n\n/**\n * A filter to convert between color spaces.\n * An example would be YUV to RGB, for mp4 to png conversion.\n */\nconst createFilter = async({\n stream,\n outputPixelFormat,\n interpolateFps,\n interpolateMode = 'fast',\n}: {\n stream: beamcoder.Stream;\n outputPixelFormat: string;\n interpolateFps?: number;\n interpolateMode?: InterpolateMode;\n}): Promise<beamcoder.Filterer> => {\n if (!stream.codecpar.format) {\n return null;\n }\n\n let filterSpec = [`[in0:v]format=${stream.codecpar.format}`];\n\n if (interpolateFps) {\n if (interpolateMode === 'high-quality') {\n filterSpec = [...filterSpec, `minterpolate=fps=${interpolateFps}`];\n }\n else if (interpolateMode === 'fast') {\n filterSpec = [...filterSpec, `fps=${interpolateFps}`];\n }\n else {\n throw new Error(`Unexpected interpolation mode: ${interpolateMode}`);\n }\n }\n\n const filterSpecStr = filterSpec.join(', ') + '[out0:v]';\n\n VERBOSE && console.log(`filterSpec: ${filterSpecStr}`);\n\n return beamcoder.filterer({\n filterType: 'video',\n inputParams: [\n {\n name: 'in0:v',\n width: stream.codecpar.width,\n height: stream.codecpar.height,\n pixelFormat: stream.codecpar.format,\n timeBase: stream.time_base,\n pixelAspect: stream.sample_aspect_ratio,\n },\n ],\n outputParams: [\n {\n name: 'out0:v',\n pixelFormat: outputPixelFormat,\n },\n ],\n filterSpec: filterSpecStr,\n });\n};\n\nconst STREAM_TYPE_VIDEO = 'video';\nconst STREAM_TYPE_AUDIO = 'audio';\nconst MAX_RECURSION = 5;\n\n/**\n * A simple extractor that uses beamcoder to extract frames from a video file.\n */\nexport class BeamcoderExtractor extends BaseExtractor implements Extractor {\n /**\n * The demuxer reads the file and outputs packet streams\n */\n #demuxer: Demuxer = null;\n\n /**\n * The decoder reads packets and can output raw frame data\n */\n #decoder: Decoder = null;\n\n /**\n * Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or\n * filters, filter might not be necessary.\n */\n #filterer: Filterer = null;\n\n /**\n * This is where we store filtered frames from each previously processed packet.\n * We keep these in chronological order. We hang on to them for two reasons:\n * 1. so we can return them if we get a request for the same time again\n * 2. so we can return frames close the end of the stream. When such a frame is requested we have to flush (destroy)\n * the encoder to get the last few frames. This avoids having to re-create an encoder.\n */\n #filteredFramesPacket: undefined[] | Array<Array<Frame>> = [];\n\n /**\n * This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We\n * do this ensure we don't skip any frames.\n */\n #frames = [];\n\n /**\n * This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do\n * this ensure we don't skip any frames.\n */\n #packet: null | Packet = null;\n\n /**\n * The last target presentation timestamp (PTS) we requested. If we never requested a time(stamp) then this\n * value is null\n */\n #previousTargetPTS: null | number = null;\n\n /**\n * The number of threads to use for decoding\n */\n #threadCount = 8;\n\n /**\n * The index of the video stream in the demuxer\n */\n #streamIndex = 0;\n\n /**\n * The number of packets we've read from the demuxer to complete the frame query\n * @private\n */\n #packetReadCount = 0;\n\n /**\n * The number of times we've recursively read packets from the demuxer to complete the frame query\n * @private\n */\n #recursiveReadCount = 0;\n\n /**\n * Encoder/Decoder construction is async, so it can't be put in a regular constructor.\n * Use and await this method to generate an extractor.\n */\n static async create(args: ExtractorArgs): Promise<BeamcoderExtractor> {\n const extractor = new BeamcoderExtractor();\n await extractor.init(args);\n return extractor;\n }\n\n async init({\n inputFileOrUrl,\n threadCount = 8,\n outputPixelFormat = 'rgba',\n }: ExtractorArgs): Promise<void> {\n this.#threadCount = threadCount;\n VERBOSE && console.log('inputFileOrUrl before pre-processing: ', inputFileOrUrl);\n if (inputFileOrUrl.startsWith('http')) {\n VERBOSE && console.log('downloading url', inputFileOrUrl);\n const downloadUrl = new DownloadVideoURL(inputFileOrUrl);\n await downloadUrl.download();\n inputFileOrUrl = downloadUrl.filepath;\n VERBOSE && console.log('finished downloading');\n }\n // Assume file url at this point\n if (!inputFileOrUrl.startsWith('file:')) {\n inputFileOrUrl = 'file:' + inputFileOrUrl;\n }\n VERBOSE && console.log('inputFileOrUrl after pre-processing: ', inputFileOrUrl);\n VERBOSE && console.log('beamcoder.protocols(): ', JSON.stringify(beamcoder.protocols()));\n this.#demuxer = await beamcoder.demuxer(inputFileOrUrl);\n VERBOSE && console.log('demuxer creation succeeded.');\n this.#streamIndex = this.#demuxer.streams.findIndex(stream => stream.codecpar.codec_type === STREAM_TYPE_VIDEO);\n\n if (this.#streamIndex === -1) {\n throw new Error(`File has no ${STREAM_TYPE_VIDEO} stream!`);\n }\n let pixelFormat = 'rgba';\n const origianlPixelFormat = this.#demuxer.streams[this.#streamIndex].codecpar.format;\n const codecName = this.#demuxer.streams[this.#streamIndex].codecpar.name;\n // vp8 and vp9 this.#demuxer.streams[this.#streamIndex].codecpar.format is 'yuv420p', but the decoder outputs yuva420p\n if (outputPixelFormat === 'original' && codecName !== 'vp8' && codecName !== 'vp9') {\n pixelFormat = origianlPixelFormat;\n }\n this.#filterer = await createFilter({\n stream: this.#demuxer.streams[this.#streamIndex],\n outputPixelFormat: pixelFormat,\n });\n }\n\n async #createDecoder() {\n // It's possible that we need to create decoder multiple times during the lifecycle of this extractor so we\n // need to make sure we destroy the old one first if it exists\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#decoder = createDecoder({\n demuxer: this.#demuxer as Demuxer,\n streamIndex: this.#streamIndex,\n threadCount: this.#threadCount,\n });\n }\n\n get duration(): number {\n // Non-A/V streams (timed-text, data) can carry durations unrelated to playback;\n // taking the max over them would inflate the reported duration.\n const maxStreamsDuration = Math.max(...this.#demuxer.streams\n .filter(s => s.codecpar.codec_type === STREAM_TYPE_VIDEO || s.codecpar.codec_type === STREAM_TYPE_AUDIO)\n .map(s => {\n const time_base = s.time_base;\n return s.duration * time_base[0] / time_base[1];\n }));\n // Webm stores it in Segment.Info.Duration\n return maxStreamsDuration || (this.ptsToTime(this.#demuxer.duration) / 1000);\n }\n\n /**\n * Width in pixels\n */\n get width(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.width;\n }\n\n /**\n * Height in pixels\n */\n get height(): number {\n return this.#demuxer.streams[this.#streamIndex].codecpar.height;\n }\n\n /**\n * Get the beamcoder Frame for a given time in seconds\n * @param targetTime\n */\n async getFrameAtTime(targetTime: number): Promise<beamcoder.Frame> {\n VERBOSE && console.log(`getFrameAtTime time(s)=${targetTime}`);\n const targetPts = Math.round(this._timeToPTS(targetTime));\n return this._getFrameAtPts(targetPts);\n }\n\n /**\n * Get imageData for a given time in seconds\n * @param targetTime\n */\n async getImageDataAtTime(targetTime: number, rgbaBufferTarget?: Uint8ClampedArray): Promise<ImageData> {\n const targetPts = Math.round(this._timeToPTS(targetTime));\n VERBOSE && console.log('targetTime', targetTime, '-> targetPts', targetPts);\n const frame = await this._getFrameAtPts(targetPts);\n if (!frame) {\n VERBOSE && console.log('no frame found');\n return null;\n }\n\n if (rgbaBufferTarget) {\n BeamcoderExtractor._setFrameDataToRGBABufferTarget(frame, rgbaBufferTarget);\n }\n\n return {\n width: frame.width,\n height: frame.height,\n frame,\n };\n }\n\n /**\n * Get the presentation timestamp (PTS) for a given time in seconds\n */\n _timeToPTS(time: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return time * time_base[1] / time_base[0];\n }\n\n /**\n * Get the time in seconds from a given presentation timestamp (PTS)\n */\n ptsToTime(pts: number) {\n const time_base = this.#demuxer.streams[this.#streamIndex].time_base;\n return pts * time_base[0] / time_base[1];\n }\n\n get packetReadCount() {\n return this.#packetReadCount;\n }\n\n /**\n * Get the frame at the given presentation timestamp (PTS)\n * @param targetPTS - the target presentation timestamp (PTS) we want to retrieve\n * @param SeekPTSOffset - the offset to use when seeking to the targetPTS. This is used when we have trouble finding\n * the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read\n * additional packets and find a frame that is closer to the targetPTS.\n */\n async _getFrameAtPts(targetPTS: number, SeekPTSOffset = 0): Promise<beamcoder.Frame> {\n VERBOSE && console.log('_getFrameAtPts', targetPTS, 'seekPTSOffset', SeekPTSOffset, 'duration', this.duration);\n this.#packetReadCount = 0;\n\n // seek and create a decoder when retrieving a frame for the first time or when seeking backwards\n // we have to create a new decoder when seeking backwards as the decoder can only process frames in\n // chronological order.\n // RE_SEEK_DELTA: sometimes, we are looking for a frame so far ahead that it's better to drop everything and seek.\n // Example: when we got a frame a 0 and request a frame at t = 30s just after, we don't want to start reading all packets\n // until 30s.\n const RE_SEEK_THRESHOLD = 3; // 3 seconds - typically we have keyframes at shorter intervals\n const hasFrameWithinThreshold = this.#filteredFramesPacket.flat().some(frame => {\n return this.ptsToTime(Math.abs(targetPTS - (frame as Frame).pts)) < RE_SEEK_THRESHOLD;\n });\n VERBOSE && console.log('hasPreviousTargetPTS:', this.#previousTargetPTS === null, ', targetPTS is smaller:', this.#previousTargetPTS > targetPTS, ', has frame within threshold:', hasFrameWithinThreshold);\n if (this.#previousTargetPTS === null || this.#previousTargetPTS > targetPTS || !hasFrameWithinThreshold) {\n VERBOSE && console.log(`Seeking to ${targetPTS + SeekPTSOffset}`);\n\n await this.#demuxer.seek({\n stream_index: 0, // even though we specify the stream index, it still seeks all streams\n timestamp: targetPTS + SeekPTSOffset,\n any: false,\n });\n await this.#createDecoder();\n this.#packet = null;\n this.#frames = [];\n this.#previousTargetPTS = targetPTS;\n this.#filteredFramesPacket = [];\n }\n\n let filteredFrames = null;\n let closestFramePTS = -1;\n let outputFrame = null;\n\n // If we have previously filtered frames, get the frame closest to our targetPTS\n if (this.#filteredFramesPacket.length > 0) {\n const closestFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts <= targetPTS) as Frame;\n\n if (closestFrame) {\n const nextFrame = this.#filteredFramesPacket\n .flat()\n .find(f => (f as Frame).pts > closestFrame.pts) as Frame;\n\n VERBOSE && console.log('returning previously filtered frame with pts', (closestFrame as Frame).pts);\n closestFramePTS = (closestFrame as Frame).pts;\n outputFrame = closestFrame;\n\n if ((nextFrame && nextFrame.pts > targetPTS) || (closestFramePTS === targetPTS)) {\n // We have a next frame, so we know the frame being displayed at targetPTS is the previous one,\n // which corresponds to outputFrame.\n this.#previousTargetPTS = targetPTS;\n return outputFrame;\n }\n }\n }\n\n // This is the first time we're decoding frames. Get the first packet and decode it.\n if (!this.#packet && this.#frames.length === 0) {\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n this.#packetReadCount++;\n }\n // Read packets until we have a frame which is closest to targetPTS\n while ((this.#packet || this.#frames.length !== 0) && closestFramePTS < targetPTS) {\n VERBOSE && console.log('packet si:', this.#packet?.stream_index, 'pts:', this.#packet?.pts, 'frames:', this.#frames?.length);\n VERBOSE && console.log('frames', this.#frames?.length, 'frames.pts:', JSON.stringify(this.#frames?.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // packet contains frames\n if (this.#frames.length !== 0) {\n // filter the frames\n const filteredResult = await this.#filterer.filter([{ name: 'in0:v', frames: this.#frames }]);\n filteredFrames = filteredResult.flatMap(r => r.frames);\n VERBOSE && console.log('filteredFrames', filteredFrames.length, 'filteredFrames.pts:', JSON.stringify(filteredFrames.map(f => f.pts)), '-> target.pts:', targetPTS);\n\n // get the closest frame to our target presentation timestamp (PTS)\n // Beamcoder returns decoded packet frames as follows: [1000, 2000, 3000, 4000]\n // If we're looking for a frame at 0, we want to return the frame at 1000\n // If we're looking for a frame at 2500, we want to return the frame at 2000\n const closestFrame = (this.#packetReadCount === 1 && filteredFrames[0].pts > targetPTS)\n ? filteredFrames[0]\n : filteredFrames.reverse().find(f => f.pts <= targetPTS);\n\n // The packet contains frames, but all of them have PTS larger than our a targetPTS (we looked too far)\n if (!closestFrame) {\n return outputFrame;\n }\n\n // store the filtered packet frames for later reuse\n this.#filteredFramesPacket.unshift(filteredFrames);\n if (this.#filteredFramesPacket.length > 2) {\n this.#filteredFramesPacket.pop();\n }\n\n closestFramePTS = closestFrame?.pts;\n VERBOSE && console.log('closestFramePTS', closestFramePTS, 'targetPTS', targetPTS);\n if (!outputFrame || closestFramePTS <= targetPTS) {\n VERBOSE && console.log('assigning outputFrame', closestFrame?.pts);\n this.#previousTargetPTS = targetPTS;\n outputFrame = closestFrame;\n }\n else {\n // break out of the loop if we've found the closest frame (and ensure we don't move to the next\n // packet by calling _getNextPacketAndDecodeFrames again) as this risks us getting a frame that is\n // after our targetPTS\n VERBOSE && console.log('breaking');\n break;\n }\n }\n // get the next packet and frames\n ({ packet: this.#packet, frames: this.#frames } = await this._getNextPacketAndDecodeFrames());\n\n // keep track of how many packets we've read\n this.#packetReadCount++;\n }\n\n // we read through all the available packets and frames, but we still don't have a frame. This can happen\n // when our targetPTS is to close to the end of the video. In this case, we'll try to seek further away from\n // the end of the video and try again. We've set up a MAX_RECURSION to prevent an infinite loop.\n if (!outputFrame) {\n if (MAX_RECURSION < this.#recursiveReadCount) {\n throw Error('No matching frame found');\n }\n const TIME_OFFSET = 0.1; // time offset in seconds\n const PTSOffset = this._timeToPTS(TIME_OFFSET);\n this.#recursiveReadCount++;\n outputFrame = await this._getFrameAtPts(targetPTS, SeekPTSOffset - PTSOffset);\n if (outputFrame) {\n this.#recursiveReadCount = 0;\n }\n }\n VERBOSE && console.log('read', this.packetReadCount, 'packets');\n\n return outputFrame;\n }\n\n /**\n * Get the next packet from the video stream and decode it into frames. Each frame has a presentation time stamp\n * (PTS). If we've reached the end of the stream and no more packets are available, we'll extract the last frames\n * from the decoder and destroy it.\n */\n async _getNextPacketAndDecodeFrames() {\n const packet = await this._getNextVideoStreamPacket();\n VERBOSE && console.log('packet pts:', packet?.pts);\n\n // extract frames from the packet\n let decodedFrames = null;\n if (packet !== null && this.#decoder) {\n decodedFrames = await this.#decoder.decode(packet as Packet);\n VERBOSE && console.log('decodedFrames', decodedFrames.frames.length, decodedFrames.frames.map(f => f.pts));\n }\n // we've reached the end of the stream\n else {\n if (this.#decoder) {\n VERBOSE && console.log('getting the last frames from the decoder');\n // flush the decoder -- this will return the last frames and destroy the decoder\n decodedFrames = await this.#decoder.flush();\n this.#decoder = null;\n }\n else {\n // we don't have a decoder, so we can't decode any more frames\n VERBOSE && console.log('no more frames to decode');\n }\n }\n\n let frames = [];\n if (decodedFrames && decodedFrames.frames.length !== 0) {\n frames = decodedFrames.frames;\n }\n VERBOSE && console.log(`returning ${frames.length} decoded frames`);\n\n return { packet, frames };\n }\n\n async _getNextVideoStreamPacket(): Promise<null | Packet> {\n VERBOSE && console.log('_getNextVideoStreamPacket');\n\n let packet = await this.#demuxer.read();\n while (packet && packet.stream_index !== this.#streamIndex) {\n packet = await this.#demuxer.read();\n if (packet === null) {\n VERBOSE && console.log('no more packets');\n return null;\n }\n }\n VERBOSE && console.log('returning packet', !!packet, 'pts', packet?.pts, 'si', packet?.stream_index);\n return packet as Packet;\n }\n\n static _setFrameDataToRGBABufferTarget(frame: beamcoder.Frame, rgbaBufferTarget: Uint8ClampedArray) {\n const sourceLineSize = frame.linesize as unknown as number;\n // frame.data can contain multiple \"planes\" in other colorspaces, but in rgba, there is just one \"plane\", so\n // our data is in frame.data[0]\n const pixels = frame.data[0] as Uint8Array;\n const width = frame.width;\n const height = frame.height;\n\n // libav creates larger buffers because it makes their internal code simpler.\n // we have to trim a part at the right of each pixel row.\n\n for (let i = 0; i < height; i++) {\n const sourceStart = i * sourceLineSize;\n const sourceEnd = sourceStart + width * RGBA_PIXEL_SIZE;\n const sourceData = pixels.subarray(sourceStart, sourceEnd);\n const targetOffset = i * width * RGBA_PIXEL_SIZE;\n rgbaBufferTarget.set(sourceData, targetOffset);\n }\n }\n\n async dispose() {\n if (this.#decoder) {\n await this.#decoder.flush();\n this.#decoder = null;\n }\n this.#demuxer.forceClose();\n this.#filterer = null;\n this.#filteredFramesPacket = undefined;\n this.#frames = [];\n this.#packet = null;\n this.#previousTargetPTS = null;\n this.#streamIndex = 0;\n }\n}\n","import { DownloadVideoURL } from './DownloadVideoURL';\n\ninterface CachedResource {\n url: string;\n filepath: string | undefined;\n download(): Promise<void>;\n destroy(): void;\n}\n\ninterface CacheEntry {\n downloader: DownloadVideoURL;\n refCount: number;\n downloadPromise?: Promise<void>;\n}\n\nexport class CachedVideoDownloader {\n #cache: Map<string, CacheEntry> = new Map();\n\n get(url: string): CachedResource {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n let filepath: string | undefined;\n\n return {\n url,\n get filepath() {\n return filepath;\n },\n\n async download() {\n let entry = self.#cache.get(url);\n\n if (entry) {\n entry.refCount += 1;\n\n // Wait for in-progress download if exists\n if (entry.downloadPromise) {\n await entry.downloadPromise;\n }\n }\n else {\n const downloader = new DownloadVideoURL(url);\n\n const promise = downloader.download();\n entry = {\n downloader,\n refCount: 1,\n downloadPromise: promise,\n };\n self.#cache.set(url, entry);\n\n try {\n await promise;\n }\n finally {\n entry.downloadPromise = undefined; // Clear after completion\n }\n }\n\n filepath = self.#cache.get(url).downloader.filepath;\n },\n\n destroy() {\n const entry = self.#cache.get(url);\n if (!entry) return;\n\n entry.refCount -= 1;\n\n if (entry.refCount <= 0) {\n entry.downloader.clear();\n self.#cache.delete(url);\n }\n\n filepath = undefined;\n },\n };\n }\n}\n"],"names":["BaseExtractor","args","inputFileOrUrl","outputFile","threadCount","endTime","interpolateFps","interpolateMode","targetPts","targetTime","pts","onFrameAvailable","flush","DownloadVideoURL","url","__privateAdd","_url","_httpRequest","_filepath","_tmpObj","__privateSet","extension","path","tmp","__privateGet","source","response","contentType","writeStream","fs","readableStream","reader","resolve","reject","pump","done","value","buffer","RGBA_PIXEL_SIZE","createDecoder","demuxer","streamIndex","commonParams","beamcoder","createFilter","stream","outputPixelFormat","filterSpec","filterSpecStr","STREAM_TYPE_VIDEO","STREAM_TYPE_AUDIO","MAX_RECURSION","_BeamcoderExtractor","_createDecoder","_demuxer","_decoder","_filterer","_filteredFramesPacket","_frames","_packet","_previousTargetPTS","_threadCount","_streamIndex","_packetReadCount","_recursiveReadCount","extractor","downloadUrl","pixelFormat","origianlPixelFormat","codecName","time_base","rgbaBufferTarget","frame","time","targetPTS","SeekPTSOffset","RE_SEEK_THRESHOLD","hasFrameWithinThreshold","__privateMethod","createDecoder_fn","filteredFrames","closestFramePTS","outputFrame","closestFrame","nextFrame","f","__privateWrapper","r","TIME_OFFSET","PTSOffset","packet","decodedFrames","frames","sourceLineSize","pixels","width","height","i","sourceStart","sourceEnd","sourceData","targetOffset","BeamcoderExtractor","CachedVideoDownloader","_cache","self","filepath","entry","downloader","promise"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,MAAMA,EAAmC;AAAA,EAC5C,aAAa,OAAOC,GAAyC;AACnD,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,KAAK;AAAA,IACP,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,EAAA,GAC6B;AACvB,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,WAAmB;AACb,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,QAAgB;AACV,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,IAAI,SAAiB;AACX,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM,UAAUC,GAAmB;AACzB,UAAA,IAAI,MAAM,iBAAiB;AAAA,EACrC;AAAA,EAEA,MAAM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F,EAAAiF,GAAAD,GAAO,IAAI1F,GAAK6F,CAAK;AAEtB,cAAA;AACM,kBAAAE;AAAA,UAAA,UAEV;AACI,YAAAF,EAAM,kBAAkB;AAAA,UAC5B;AAAA;AAGJ,QAAAD,IAAWlF,EAAAiF,GAAKD,GAAO,IAAI1F,CAAG,EAAE,WAAW;AAAA,MAC/C;AAAA,MAEA,UAAU;AACN,cAAM6F,IAAQnF,EAAAiF,GAAKD,GAAO,IAAI1F,CAAG;AACjC,QAAK6F,MAELA,EAAM,YAAY,GAEdA,EAAM,YAAY,MAClBA,EAAM,WAAW,SACZnF,EAAAiF,GAAAD,GAAO,OAAO1F,CAAG,IAGf4F,IAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAER;AACJ;AA9DIF,IAAA;"}
|
|
@@ -75,6 +75,7 @@ const createFilter = async ({ stream, outputPixelFormat, interpolateFps, interpo
|
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
77
|
const STREAM_TYPE_VIDEO = 'video';
|
|
78
|
+
const STREAM_TYPE_AUDIO = 'audio';
|
|
78
79
|
const MAX_RECURSION = 5;
|
|
79
80
|
/**
|
|
80
81
|
* A simple extractor that uses beamcoder to extract frames from a video file.
|
|
@@ -191,12 +192,14 @@ export class BeamcoderExtractor extends BaseExtractor {
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
get duration() {
|
|
195
|
+
// Non-A/V streams (timed-text, data) can carry durations unrelated to playback;
|
|
196
|
+
// taking the max over them would inflate the reported duration.
|
|
194
197
|
const maxStreamsDuration = Math.max(...this.#demuxer.streams
|
|
198
|
+
.filter(s => s.codecpar.codec_type === STREAM_TYPE_VIDEO || s.codecpar.codec_type === STREAM_TYPE_AUDIO)
|
|
195
199
|
.map(s => {
|
|
196
200
|
const time_base = s.time_base;
|
|
197
201
|
return s.duration * time_base[0] / time_base[1];
|
|
198
202
|
}));
|
|
199
|
-
// MP4 duration is defined as the longest stream duration
|
|
200
203
|
// Webm stores it in Segment.Info.Duration
|
|
201
204
|
return maxStreamsDuration || (this.ptsToTime(this.#demuxer.duration) / 1000);
|
|
202
205
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beamcoder.js","sourceRoot":"","sources":["../../../src/backends/beamcoder.ts"],"names":[],"mappings":"AAOA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,MAAM,aAAa,GAAG,CAAC,EACnB,OAAO,EACP,WAAW,EACX,WAAW,GAKd,EAAW,EAAE;IACV,MAAM,YAAY,GAAG;QACjB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK;QAClD,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM;QACrD,YAAY,EAAE,WAAW;KAC5B,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,EAAE;QACtD,OAAO,SAAS,CAAC,OAAO,CAAC;YACrB,GAAG,YAAY;YACf,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAC;KACN;IAED,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,EAAE;QACtD,OAAO,SAAS,CAAC,OAAO,CAAC;YACrB,GAAG,YAAY;YACf,IAAI,EAAE,YAAY;SACrB,CAAC,CAAC;KACN;IAED,OAAO,SAAS,CAAC,OAAO,CAAC;QACrB,GAAG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