mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Give Matroska subtitle cues a BlockDuration (#442)
Subtitle cues were written as SimpleBlocks, which carry no duration. A SimpleBlock tells the player when a cue starts but not how long to show it, so players such as VLC and libass-based renderers display nothing for S_TEXT/WEBVTT tracks muxed into Matroska/WebM. Route a subtitle chunk that has a positive duration through a BlockGroup so its BlockDuration is written, matching how additions are already handled. Non-subtitle tracks and zero-duration cues keep using SimpleBlocks. Co-authored-by: hikari <[email protected]>
This commit is contained in:
@@ -1168,7 +1168,12 @@ export class MatroskaMuxer extends Muxer {
|
||||
|
||||
const msDuration = Math.round(1000 * chunk.duration);
|
||||
|
||||
if (!chunk.additions) {
|
||||
// Subtitle cues need an explicit BlockDuration (a SimpleBlock has none), otherwise players
|
||||
// like VLC/libass don't know how long to show the cue and render nothing. So a subtitle with
|
||||
// a duration must go into a BlockGroup even when it has no additions.
|
||||
const needsBlockGroup = !!chunk.additions || (trackData.type === 'subtitle' && msDuration > 0);
|
||||
|
||||
if (!needsBlockGroup) {
|
||||
// No additions, we can write out a SimpleBlock
|
||||
view.setUint8(3, Number(chunk.type === 'key') << 7); // Flags (keyframe flag only present for SimpleBlock)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user