Skip to content

Commit

Permalink
Merge pull request #40 from Lumen5/LU-2854-fix
Browse files Browse the repository at this point in the history
Another seeking fix
  • Loading branch information
animanathome committed May 15, 2023
2 parents 500c8ff + fc9b820 commit b5395a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lumen5/framefusion",
"version": "0.0.21",
"version": "0.0.22",
"type": "module",
"scripts": {
"docs": "typedoc framefusion.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/backends/beamcoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions test/framefusion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit b5395a3

Please sign in to comment.