1. Go to this page and download the library: Download saeven/subtitles library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
saeven / subtitles example snippets
// add namespace
use \Circlical\Subtitles\Subtitles;
(new Subtitles())->load($srtContent, 'srt')->content('vtt');
$subtitles = new Subtitles();
$subtitles->add(0, 5, 'This text is shown in the beggining of video for 5 seconds');
file_put_contents( './foo', $subtitles->content('subtitles.vtt'));
$string = "
1
00:02:17,440 --> 00:02:20,375
Senator, we're making our final approach
";
$subtitles = Subtitles::load($string, 'srt');
echo $subtitles->content('vtt');
$subtitles->add(0, 5, 'some text'); // from 0, till 5 seconds
// Add multiline text
$subtitles->add(0, 5, [
'first line',
'second line',
]);
$subtitles->remove(0, 5); // from 0, till 5 seconds