This library provides methods for working with closed caption files in a standard way from within PHP.
MIT - See LICENCE file.
It's alway nice to hear about people using your code, so if you use this library in your code feel free to let me know. It gives me warm fuzzies and motivates me to keep writing.
- Parse & Render SRT Files
- Render Dfxp (TTML) Files
- Time shift all captions from the start, or a given caption index
- Support parsing DFXP format
- Support Shrinking and enlarging of individual caption times
- SRT Caption positioning support
- SRT & Dfxp Style Support
$captions = Captions::from_srt(file_get_contents("my_captions.srt"));
// Returns instance of Captions_Set
$captions = new Captions_Set;
$caption = new Captions_Caption;
$caption->text("And then I said, but what about the monkeys?")
->start(0)
->end(8.340);
$captions->add_caption($caption);
$captions->rewind(1.5); // Rewinds all captions 1.5 seconds
$captions->fast_forward(2.5, 8); // Fast forwards all captions from caption #8 onwards by 2.5 seconds
$captions->renderer(new Captions_Renderer_SrtRenderer);
echo $captions->render();
// Or
$captions->render("my_new_captions.srt");
$renderer = new Captions_Renderer_DfxpRenderer;
$renderer->render($captions, "my_captions.xml"); // File output parameter optional (return string)
Tests are in the tests folder and require simpletest Completed 4 of 4 tests in 1.35 seconds with 0 failures