@@ -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 ;
0 commit comments