@@ -316,6 +316,142 @@ describe(testName, () => {
316
316
audioEncoder . release ( ) ;
317
317
} ) ;
318
318
319
+ it ( 'Start simple recording - mpegts' , async function ( ) {
320
+ if ( obs . isDarwin ( ) ) {
321
+ this . skip ( ) ;
322
+ }
323
+
324
+ const formats : ERecordingFormat [ ] = [
325
+ ERecordingFormat . MP4 ,
326
+ ERecordingFormat . MOV ,
327
+ ERecordingFormat . MKV ,
328
+ ERecordingFormat . FLV ,
329
+ ERecordingFormat . TS ,
330
+ ERecordingFormat . M3U8 ,
331
+ ] ;
332
+ for ( const format of formats ) {
333
+ const recording = osn . SimpleRecordingFactory . create ( ) ;
334
+
335
+ recording . path = path . join ( path . normalize ( __dirname ) , ".." , "osnData" ) ;
336
+ recording . format = format as ERecordingFormat ;
337
+ recording . quality = ERecordingQuality . HighQuality ;
338
+ recording . video = obs . defaultVideoContext ;
339
+ recording . videoEncoder = osn . VideoEncoderFactory . create (
340
+ "obs_x264" ,
341
+ `video-encoder-recording-${ format } `
342
+ ) ;
343
+ recording . lowCPU = false ;
344
+ recording . audioEncoder = osn . AudioEncoderFactory . create (
345
+ "ffmpeg_aac" ,
346
+ `audio-encoder-simple-recording-${ format } `
347
+ ) ;
348
+ recording . overwrite = false ;
349
+ recording . noSpace = false ;
350
+ recording . signalHandler = ( signal ) => obs . signals . push ( signal ) ;
351
+
352
+ /* ---------- start ---------- */
353
+ recording . start ( ) ;
354
+
355
+ let signalInfo = await obs . getNextSignalInfo (
356
+ EOBSOutputType . Recording ,
357
+ EOBSOutputSignal . Start
358
+ ) ;
359
+
360
+ if ( signalInfo . signal === EOBSOutputSignal . Stop ) {
361
+ throw Error (
362
+ GetErrorMessage (
363
+ ETestErrorMsg . RecordOutputDidNotStart ,
364
+ signalInfo . code . toString ( ) ,
365
+ signalInfo . error
366
+ )
367
+ ) ;
368
+ }
369
+
370
+ expect ( signalInfo . type ) . to . equal (
371
+ EOBSOutputType . Recording ,
372
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
373
+ ) ;
374
+ expect ( signalInfo . signal ) . to . equal (
375
+ EOBSOutputSignal . Start ,
376
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
377
+ ) ;
378
+
379
+ await sleep ( 2500 ) ;
380
+
381
+ /* ---------- stop ---------- */
382
+ recording . stop ( ) ;
383
+
384
+ signalInfo = await obs . getNextSignalInfo (
385
+ EOBSOutputType . Recording ,
386
+ EOBSOutputSignal . Stopping
387
+ ) ;
388
+
389
+ expect ( signalInfo . type ) . to . equal (
390
+ EOBSOutputType . Recording ,
391
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
392
+ ) ;
393
+ expect ( signalInfo . signal ) . to . equal (
394
+ EOBSOutputSignal . Stopping ,
395
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
396
+ ) ;
397
+
398
+ signalInfo = await obs . getNextSignalInfo (
399
+ EOBSOutputType . Recording ,
400
+ EOBSOutputSignal . Stop
401
+ ) ;
402
+
403
+ if ( signalInfo . code !== 0 ) {
404
+ throw Error (
405
+ GetErrorMessage (
406
+ ETestErrorMsg . RecordOutputStoppedWithError ,
407
+ signalInfo . code . toString ( ) ,
408
+ signalInfo . error
409
+ )
410
+ ) ;
411
+ }
412
+
413
+ expect ( signalInfo . type ) . to . equal (
414
+ EOBSOutputType . Recording ,
415
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
416
+ ) ;
417
+ expect ( signalInfo . signal ) . to . equal (
418
+ EOBSOutputSignal . Stop ,
419
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
420
+ ) ;
421
+
422
+ signalInfo = await obs . getNextSignalInfo (
423
+ EOBSOutputType . Recording ,
424
+ EOBSOutputSignal . Wrote
425
+ ) ;
426
+
427
+ if ( signalInfo . code !== 0 ) {
428
+ throw Error (
429
+ GetErrorMessage (
430
+ ETestErrorMsg . RecordOutputStoppedWithError ,
431
+ signalInfo . code . toString ( ) ,
432
+ signalInfo . error
433
+ )
434
+ ) ;
435
+ }
436
+
437
+ expect ( signalInfo . type ) . to . equal (
438
+ EOBSOutputType . Recording ,
439
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
440
+ ) ;
441
+ expect ( signalInfo . signal ) . to . equal (
442
+ EOBSOutputSignal . Wrote ,
443
+ GetErrorMessage ( ETestErrorMsg . RecordingOutput )
444
+ ) ;
445
+
446
+ // cleanup for this format
447
+ const videoEncoder = recording . videoEncoder ;
448
+ const audioEncoder = recording . audioEncoder ;
449
+ osn . SimpleRecordingFactory . destroy ( recording ) ;
450
+ videoEncoder . release ( ) ;
451
+ audioEncoder . release ( ) ;
452
+ }
453
+ } ) ;
454
+
319
455
it ( 'Start simple recording - HigherQuality' , async function ( ) {
320
456
if ( obs . isDarwin ( ) ) {
321
457
this . skip ( ) ;
0 commit comments