player icon indicating copy to clipboard operation
player copied to clipboard

Support srt file format

Open tbaddade opened this issue 5 months ago • 1 comments

Original file format

1
00:00:01,000 --> 00:00:05,000
Welcome

2
00:00:06,000 --> 00:00:10,000
Example with comma

3
00:00:11,000 --> 00:00:15,000
Thanks

Adapted file format (Comma replaced by point.)

1
00:00:01.000 --> 00:00:05.000
Welcome

2
00:00:06.000 --> 00:00:10.000
Example with point

3
00:00:11.000 --> 00:00:15.000
Thanks

The manually adjusted file format works, so it would be nice if Vidstack could also accept the comma in the timestamp.

tbaddade avatar Jul 18 '25 11:07 tbaddade

Hi @tbaddade, I’ve reproduced the issue and fixed the parseText() function in #1716. I’ve tested it, and I’m not having any problems with the SRT format. The issue is caused by the media-captions package, which doesn’t automatically detect the correct format. During configuration, you need to specify the format using the type attribute.

const tracks: TextTrackInit[] = [{
    type: 'srt',
    src: 'https://example.com/english.srt',
    label: 'English',
    language: 'en-US',
    kind: 'subtitles',
    default: true,
}];

or

const tracks: TextTrackInit[] = [{
    type: 'srt',
    content: `
      1
      00:00:01,000 --> 00:00:05,000
      Welcome
      
      2
      00:00:06,000 --> 00:00:10,000
      Example with comma
      
      3
      00:00:11,000 --> 00:00:15,000
      Thanks
    `,
    label: 'English',
    language: 'en-US',
    kind: 'subtitles',
    default: true,
}];

Thank you!

pzanella avatar Oct 29 '25 10:10 pzanella