Skip to content

Commit f74ae64

Browse files
committed
test record formats
1 parent c7445bf commit f74ae64

File tree

3 files changed

+140
-4
lines changed

3 files changed

+140
-4
lines changed

js/module.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ export declare const enum ERecordingFormat {
753753
FLV = "flv",
754754
MOV = "mov",
755755
MKV = "mkv",
756-
TS = "mpegts",
757-
M3M8 = "m3m8"
756+
TS = "ts",
757+
M3U8 = 'm3u8'
758758
}
759759
export declare const enum ERecordingQuality {
760760
Stream = 0,

js/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,8 @@ export const enum ERecordingFormat {
16521652
FLV = 'flv',
16531653
MOV = 'mov',
16541654
MKV = 'mkv',
1655-
TS = 'mpegts',
1656-
M3M8 = 'm3m8'
1655+
TS = 'ts',
1656+
M3U8 = 'm3u8'
16571657
}
16581658

16591659
export const enum ERecordingQuality {

tests/osn-tests/src/test_osn_simple_recording.ts

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,142 @@ describe(testName, () => {
316316
audioEncoder.release();
317317
});
318318

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+
319455
it('Start simple recording - HigherQuality', async function () {
320456
if (obs.isDarwin()) {
321457
this.skip();

0 commit comments

Comments
 (0)