Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
animanathome committed Oct 28, 2024
1 parent 0e5fe70 commit 060f966
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/backends/beamcoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ const VERBOSE = false;
*/
const RGBA_PIXEL_SIZE = 4;

// Convert a duration string in the format HH:MM:SS to seconds
// Example: 00:01:30 -> 90
function convertDurationToSeconds(duration) {
const [hours, minutes, seconds] = duration.split(':').map(parseFloat);
return hours * 3600 + minutes * 60 + seconds;
}

const createDecoder = ({
demuxer,
streamIndex,
Expand Down Expand Up @@ -253,10 +246,7 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor {
if (stream.duration !== null) {
return this.ptsToTime(stream.duration);
}
if (stream?.metadata?.DURATION) {
return convertDurationToSeconds(stream.metadata.DURATION);
}
return 0;
return this.ptsToTime(this.#demuxer.duration) / 1000;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/framefusion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ describe('FrameFusion', () => {
await extractor.dispose();
});

it('can get duration from webm', async() => {
it.only('can get duration from webm', async() => {
// Arrange
const extractor = await BeamcoderExtractor.create({
inputFileOrUrl: 'https://storage.googleapis.com/lumen5-prod-video/anita-6uTzyZtNRKztypC.webm',
});

// Act and Assert
expect(extractor.duration).to.equal(115);
expect(extractor.duration).to.equal(115.248);

// Cleanup
await extractor.dispose();
Expand Down

0 comments on commit 060f966

Please sign in to comment.