Skip to content

Commit 302e240

Browse files
committed
Fix a bug in FragmentListBuilder
1 parent 8086274 commit 302e240

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/fragment-list-builder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class FragmentListBuilder {
1010
static build(movie, fragmentDuration) {
1111
let fragmentList = new FragmentList();
1212
fragmentList.fragmentDuration = fragmentDuration;
13-
fragmentList.duration = movie.duration;
13+
fragmentList.duration = movie.duration * FRAGMENT_TIMESCALE / movie.timescale;
1414
fragmentList.timescale = FRAGMENT_TIMESCALE;
1515
let videoTrack = movie.videoTrack();
1616
if (videoTrack) {
@@ -43,11 +43,11 @@ class FragmentListBuilder {
4343
let samples = movie.samples();
4444
let sample = null;
4545
let pos = 0;
46-
let targetFragmentDuration = movie.timescale * fragmentDuration;
46+
let targetFragmentDuration = fragmentList.timescale * fragmentDuration;
4747
for (let i = 0, l = samples.length; i < l; i++) {
4848
sample = samples[i];
4949
if (sample instanceof VideoSample && sample.keyframe) {
50-
timestamp = movie.timescale * sample.relativeTimestamp();
50+
timestamp = fragmentList.timescale * sample.relativeTimestamp();
5151
duration = timestamp - timebase;
5252
if (duration >= targetFragmentDuration) {
5353
timebase = timestamp;
@@ -59,7 +59,7 @@ class FragmentListBuilder {
5959
}
6060
}
6161
if (pos < samples.length - 1) {
62-
fragment.duration = duration;
62+
fragment.duration = fragmentList.duration - timebase;
6363
fragment.samples = samples.slice(pos, samples.length);
6464
}
6565
return fragmentList;

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-video-lib",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "Node.js Video Library",
55
"license": "MIT",
66
"main": "index",
@@ -31,12 +31,12 @@
3131
"prepublish": "npm prune",
3232
"test": "mocha ./test/tests.js",
3333
"performance-test": "mocha ./test/performance-test.js",
34-
"eslint": "eslint \"lib/**\""
34+
"lint": "eslint \"lib/**\""
3535
},
3636
"devDependencies": {
3737
"chai": "^4.1.2",
38-
"eslint": "^4.17.0",
38+
"eslint": "^4.18.2",
3939
"faker": "^4.1.0",
40-
"mocha": "^5.0.0"
40+
"mocha": "^5.0.4"
4141
}
4242
}

0 commit comments

Comments
 (0)