Skip to content

Commit

Permalink
Add subtitle features to declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanilagy committed Dec 31, 2023
1 parent 80f4e98 commit d695e62
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 18 deletions.
72 changes: 71 additions & 1 deletion build/webm-muxer.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build/webm-muxer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions build/webm-muxer.min.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions build/webm-muxer.min.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/webm-muxer.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/muxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class Muxer<T extends Target> {
this.#maybeFlushStreamingTargetWriter();
}

addSubtitleChunk(chunk: EncodedSubtitleChunk, meta: EncodedSubtitleChunkMetadata) {
addSubtitleChunk(chunk: EncodedSubtitleChunk, meta: EncodedSubtitleChunkMetadata, timestamp?: number) {
this.#ensureNotFinalized();
if (!this.#options.subtitles) throw new Error('No subtitle track declared.');

Expand All @@ -501,7 +501,7 @@ export class Muxer<T extends Target> {
let subtitleChunk = this.#createInternalChunk(
chunk.body,
'key',
chunk.timestamp,
timestamp ?? chunk.timestamp,
SUBTITLE_TRACK_NUMBER,
chunk.duration,
chunk.additions
Expand Down
2 changes: 1 addition & 1 deletion src/subtitles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class SubtitleEncoder {

let chunk: EncodedSubtitleChunk = {
body: textEncoder.encode(body),
additions: additions === '\n\n' ? undefined : textEncoder.encode(additions),
additions: additions.trim() === '' ? undefined : textEncoder.encode(additions),
timestamp: startTime * 1000,
duration: duration * 1000
};
Expand Down

0 comments on commit d695e62

Please sign in to comment.