pouyacodes / suber
此包的最新版本(dev-master)没有可用的许可信息。
使用php处理字幕
dev-master
2021-09-28 08:16 UTC
This package is not auto-updated.
Last update: 2024-09-28 08:06:53 UTC
README
使用php处理字幕
安装
首先,您必须安装 Composer。
通过Composer安装
运行 composer require pouyacodes/suber
使用git安装
- 关闭此项目
git clone https://github.com/pouyacodes/suber.git
- 运行
composer dump-autoload
- 自动加载类。
用法
以下是此包的简单用法示例
<?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. ?>