@@ -79,6 +79,44 @@ describe('File Creation', () => {
7979 expect ( ds . buffer . byteLength ) . toBe ( 40_591 ) ;
8080 } ) ;
8181
82+ it ( 'should create fragments with 1 sample each' , async ( ) => {
83+ const { samples, decoderConfig } = await collectTestSamples ( ) ;
84+
85+ const mp4 = createFile ( ) ;
86+ const track = mp4 . addTrack ( {
87+ timescale : 100 ,
88+ avcDecoderConfigRecord : decoderConfig ,
89+ width : 320 ,
90+ height : 180 ,
91+ } ) ;
92+
93+ mp4 . setSegmentOptions ( track , undefined , {
94+ nbSamplesPerFragment : 1 ,
95+ rapAlignement : false ,
96+ } ) ;
97+
98+ const fragmentBuffers : Array < ArrayBuffer > = [ ] ;
99+ mp4 . onSegment = ( id , user , buffer ) => {
100+ fragmentBuffers . push ( buffer ) ;
101+ } ;
102+
103+ const { buffer : initBuffer } = mp4 . initializeSegmentation ( ) ;
104+ mp4 . start ( ) ;
105+
106+ for ( const sample of samples ) {
107+ mp4 . addSample ( track , sample . data , {
108+ duration : sample . duration ,
109+ cts : sample . cts ,
110+ dts : sample . dts ,
111+ is_sync : sample . is_sync ,
112+ } ) ;
113+ }
114+ mp4 . flush ( ) ;
115+
116+ expect ( initBuffer . byteLength ) . toBeGreaterThan ( 0 ) ;
117+ expect ( fragmentBuffers . length ) . toBe ( samples . length ) ;
118+ } ) ;
119+
82120 it ( 'should not fail with incomplete mdat' , async ( ) => {
83121 const { testFile } = getFilePath ( 'isobmff' , '17_negative_ctso.mp4' ) ;
84122 const mp4 = createFile ( false ) ;
0 commit comments