Add maximumPageDuration Ogg muxer option (closes #277)

This commit is contained in:
Vanilagy
2026-01-13 13:37:34 +01:00
parent 571fbb3198
commit 2ab1be3834
4 changed files with 106 additions and 17 deletions
+12
View File
@@ -725,6 +725,12 @@ export class WavOutputFormat extends OutputFormat {
* @public
*/
export type OggOutputFormatOptions = {
/**
* The maximum duration of each Ogg page, in seconds. This is useful for streaming contexts where more frequent page
* output is desired. By default, pages are only flushed when they exceed a certain size.
*/
maximumPageDuration?: number;
/**
* Will be called for each Ogg page that is written.
*
@@ -749,6 +755,12 @@ export class OggOutputFormat extends OutputFormat {
if (!options || typeof options !== 'object') {
throw new TypeError('options must be an object.');
}
if (
options.maximumPageDuration !== undefined
&& (!Number.isFinite(options.maximumPageDuration) || options.maximumPageDuration <= 0)
) {
throw new TypeError('options.maximumPageDuration, when provided, must be a positive number.');
}
if (options.onPage !== undefined && typeof options.onPage !== 'function') {
throw new TypeError('options.onPage, when provided, must be a function.');
}