diff --git a/docs/guide/converting-media-files.md b/docs/guide/converting-media-files.md index 04cd301..8a3daa4 100644 --- a/docs/guide/converting-media-files.md +++ b/docs/guide/converting-media-files.md @@ -181,9 +181,9 @@ Use the `codec` property to control the codec of the output track. This should b Use the `bitrate` property to control the bitrate of the output video. For example, you can use this field to compress the video track. Accepted values are the number of bits per second or a [subjective quality](./media-sources#subjective-qualities). If this property is set, transcoding will always happen. If this property is not set but transcoding is still required, `QUALITY_HIGH` will be used as the value. -Use the `keyFrameInterval` property to control the interval in seconds between key frames in the output video. +Use the `keyFrameInterval` property to control the maximum interval in seconds between key frames in the output video. Setting this fields forces a transcode. -If you want to prevent direct copying of media data and force a transcoding step, use `forceTranscode: true`. Setting `keyFrameInterval` or `frameRate` will automatically force transcoding, even if `forceTranscode` is not explicitly set to `true`. +If you want to prevent direct copying of media data and force a transcoding step, use `forceTranscode: true`. ## Audio options diff --git a/src/conversion.ts b/src/conversion.ts index e8033f5..8b75826 100644 --- a/src/conversion.ts +++ b/src/conversion.ts @@ -167,8 +167,11 @@ export type ConversionVideoOptions = { */ alpha?: 'discard' | 'keep'; /** - * The desired interval in seconds between key frames in the output video. - * Setting this value will force transcoding (even if `forceTranscode` is not explicitly set to `true`). + * The interval, in seconds, of how often frames are encoded as a key frame. The default is 5 seconds. Frequent key + * frames improve seeking behavior but increase file size. When using multiple video tracks, you should give them + * all the same key frame interval. + * + * Setting this fields forces a transcode. */ keyFrameInterval?: number; /** When `true`, video will always be re-encoded instead of directly copying over the encoded samples. */ @@ -259,9 +262,9 @@ const validateVideoOptions = (videoOptions: ConversionVideoOptions | undefined) } if ( videoOptions?.keyFrameInterval !== undefined - && (!Number.isFinite(videoOptions.keyFrameInterval) || videoOptions.keyFrameInterval <= 0) + && (!Number.isFinite(videoOptions.keyFrameInterval) || videoOptions.keyFrameInterval < 0) ) { - throw new TypeError('options.video.keyFrameInterval, when provided, must be a finite positive number.'); + throw new TypeError('config.keyFrameInterval, when provided, must be a non-negative number.'); } };