Skip to content

Spaces being added in meta header #135

@EricAveritt

Description

@EricAveritt

Currently we are using video.js and exoplayer for some devices to play our content and are using node-webvtt version "^1.9.4"
Our current .vtt files have a meta header that looks like this:

WEBVTT
X-TIMESTAMP-MAP=MPEGTS:183750,LOCAL:00:00:00.000

However after running our .vtt file through the compile() method, we are noticing that a space is being added after the semicolon in the meta header.

WEBVTT
X-TIMESTAMP-MAP=MPEGTS: 183750,LOCAL:00:00:00.000

This is causing video.js and exoplayer to have issues loading captions due to an error with X-TIMESTAMP-MAP and the caption files are not being displayed.

Looking in the compiler.js, I noticed this section of code which deliberately adds a space to the output:

if (input.meta) {
    if (typeof input.meta !== 'object' || Array.isArray(input.meta)) {
      throw new CompilerError('Metadata must be an object');
    }

    Object.entries(input.meta).forEach((i) => {
      if (typeof i[1] !== 'string') {
        throw new CompilerError(`Metadata value for "${i[0]}" must be string`);
      }

      output += `${i[0]}: ${i[1]}\n`;
    });
  }

(https://github.com/osk/node-webvtt/blob/master/lib/compiler.js#L44)
And I am wondering what the reasoning is behind adding that space there in the output section?
Some players handle it correctly but not every player does and by removing that space both video.js and exoplayer were able to render the caption correctly and have it displayed.

Would it be possible to get this space removed in the meta if block?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions