pouyacodes / suber
There is no license information available for the latest version (dev-master) of this package.
Working with subtitles in php
dev-master
2021-09-28 08:16 UTC
This package is not auto-updated.
Last update: 2024-04-27 06:20:02 UTC
README
Working with subtitles in php
Installation
First of all you must install Composer.
Installing via Composer
run composer require pouyacodes/suber
Installing with git
- Close this project
git clone https://github.com/pouyacodes/suber.git
- run
composer dump-autoload
- autoload classes.
Usage
Here are a simple usage of this package:
<?php require_once 'vendor/autoload.php'; // Put Composer autoloader here, this can be different on your system. $content = file_get_contents("sample.srt"); // Read subtitle file's content to parse. $parser = new SrtParser; // Instantiate of SrtParser $subtitles = $parser->parse($content); // Pass content to parse. foreach($subtitles as $subtitle) { // loop through it. In this example all subtitles will delay 0.5 seconds (500 milliseconds). $subtitle->setFrom( $subtitle->getFrom() + 0.5 ); $subtitle->setTo( $subtitle->getTo() + 0.5 ); } $content = $parser->dump($subtitles); // Pass subtitle collection to dump method to get raw contents. file_put_contents("sample.fixed.srt", $content); // Save raw contents to file. ?>