Search by

podlove / webvtt-parser

eteubert

PHP library to parse webvtt

Package info

github.com/podlove/webvtt-parser

pkg:composer/podlove/webvtt-parser

Statistics

Installs: 564 762

Dependents: 0

Suggesters: 0

Stars: 16

Open Issues: 3

v1.1.6 2022-07-25 17:45 UTC

This package is auto-updated.

Last update: 2026-08-26 02:54:31 UTC


README

PHP library to parse WebVTT files.

It follows the W3C spec, but it's not complete. For example, it does not have special treatment for CSS styles.

Usage

use Podlove\Webvtt\Parser;
use Podlove\Webvtt\ParserException;

$parser = new Podlove\Webvtt\Parser();
$content = "WEBVTT\n\n00:00:00.000 --> 01:22:33.440\nHello world\n\n01:22:33.440 --> 01:22:34.440\n<v Eric>Hi again\n";
$result = $parser->parse($content);
// [
//   "cues" => [
//     [
//       "voice" => "",
//       "start" => 0,
//       "end" => 4953.44,
//       "text" => "Hello world",
//       "identifier" => "",
//     ],
//     [
//       "voice" => "Eric",
//       "start" => 4953.44,
//       "end" => 4954.44,
//       "text" => "Hi again",
//       "identifier" => "",
//     ],
//   ],
// ]