Allow fractional frame rates in track metadata, document frameRate better, other small doc adjustments

This commit is contained in:
Vanilagy
2025-04-28 15:48:51 +02:00
parent cf19e0dcf1
commit e527fe1484
10 changed files with 113 additions and 41 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ track.type; // => 'video' | 'audio' | 'subtitle';
track.isVideoTrack(); // => boolean
track.isAudioTrack(); // => boolean
// Retrieve the track's language as an ISO 639-2 language code.
// Retrieve the track's language as an ISO 639-2/T language code.
// Resolves to 'und' (undetermined) if the language isn't known.
track.languageCode; // => string
```
+15 -4
View File
@@ -42,11 +42,13 @@ For each track you want to add, you'll need to create a unique [media source](./
Optionally, you can specify additional track metadata when adding tracks:
```ts
// This specifies that the video track should be rotated by 90 degrees clockwise
// before being displayed by video players, and that a frame rate of 30 FPS is
// expected.
// This specifies that the video track should be rotated by 90 degrees
// clockwise before being displayed by video players, and that a frame rate
// of 30 FPS is expected.
output.addVideoTrack(videoSource, {
rotation: 90, // Clockwise rotation in degrees
// Clockwise rotation in degrees
rotation: 90,
// Expected frame rate in hertz
frameRate: 30,
});
@@ -66,6 +68,15 @@ output.addSubtitleTrack(subtitleSourceFre, { language: 'fre' });
output.addSubtitleTrack(subtitleSourceIta, { language: 'ita' });
```
::: info
The optional `frameRate` video track metadata option specifies the expected frame rate of the video. All timestamps and durations of frames that will be added to this track will be snapped to the specified frame rate. You should avoid adding frames more often than the rate permits, as this will lead to multiple frames having the same timestamp.
To precisely achieve common fractional frame rates, make sure to use their exact fractional forms:
$23.976 \rightarrow 24000/1001$\
$29.97 \rightarrow 30000/1001$\
$59.94 \rightarrow 60000/1001$
:::
As an example, let's add two tracks to our output:
- A video track driven by the contents of a `<canvas>` element, encoded using AVC
- An audio track driven by the user's microphone input, encoded using AAC
+1 -2
View File
@@ -35,5 +35,4 @@ things the guide needs to cover:
- utility functions
- supported containers / codecs
- samples & packets
- conversion
- do a part that "frameRate" must be an integer. and make sure to document numbers that can only be integer in the docblocks
- conversion