From 73d4c27088a8219e7e1c5b45cfada999481fd16d Mon Sep 17 00:00:00 2001 From: animanathome Date: Fri, 12 May 2023 16:36:44 -0700 Subject: [PATCH 1/2] seeking fix --- src/backends/beamcoder.ts | 2 ++ test/framefusion.test.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/backends/beamcoder.ts b/src/backends/beamcoder.ts index 6fcf671..26f1511 100644 --- a/src/backends/beamcoder.ts +++ b/src/backends/beamcoder.ts @@ -338,6 +338,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor { if ((nextFrame && nextFrame.pts > targetPTS) || (closestFramePTS === targetPTS)) { // We have a next frame, so we know the frame being displayed at targetPTS is the previous one, // which corresponds to outputFrame. + this.#previousTargetPTS = targetPTS; return outputFrame; } } @@ -380,6 +381,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor { VERBOSE && console.log('closestFramePTS', closestFramePTS, 'targetPTS', targetPTS); if (!outputFrame || closestFramePTS <= targetPTS) { VERBOSE && console.log('assigning outputFrame', closestFrame?.pts); + this.#previousTargetPTS = targetPTS; outputFrame = closestFrame; } else { diff --git a/test/framefusion.test.ts b/test/framefusion.test.ts index a7c8ea0..fb8d2de 100644 --- a/test/framefusion.test.ts +++ b/test/framefusion.test.ts @@ -235,6 +235,18 @@ describe('FrameFusion', () => { await extractor.dispose(); }); + it('can get frames when looping', async() => { + const extractor = await BeamcoderExtractor.create({ + inputFileOrUrl: 'https://media-share.lumen5.com/proxy-url/?url=https%3A%2F%2Fmedia.tenor.com%2F37odVJNnxHEAAAPo%2Fdominos-dominos-pizza.mp4', + }); + + const times = [0.012667, 1.212667, 1.246, 0.012666]; + for (let i = 0; i < times.length; i++) { + const frame = await extractor.getFrameAtTime(times[i]); + expect(Math.floor(extractor.ptsToTime(frame.pts))).to.equal(Math.floor(times[i])); + } + }); + it('can get the first 10 frames', async() => { // Arrange const extractor = await BeamcoderExtractor.create({ From fc9b82053a5aa86b00d751a5f49b9e4ce2c9d567 Mon Sep 17 00:00:00 2001 From: animanathome Date: Fri, 12 May 2023 16:43:04 -0700 Subject: [PATCH 2/2] updating version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e721689..8cdae87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lumen5/framefusion", - "version": "0.0.21", + "version": "0.0.22", "type": "module", "scripts": { "docs": "typedoc framefusion.ts",