承接 saeven/subtitles 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saeven/subtitles

Composer 安装命令:

composer require saeven/subtitles

包简介

Subtitle converter and generator for PHP

README 文档

README

Convert and edit subtitles and captions.

Supported formats

Format Extension
SubRip .srt
WebVTT .vtt
Youtube Subtitles .sbv

Installation

composer require saeven/subtitles

Fork Notes

This package was forked from mantas-done/subtitles (thank you) to become more opinionated, to implement strict types and new interfaces, and to implement proper PSR-4 loading. What's more, this version of that package removes all ability to manipulate files directly or to attempt to infer the existence of converters by scanning the filesystem with file_exists and so forth. It also resorts to pattern matching in cases where the original implementation would split strings. Lastly, it adds Carbon to perform time conversions.

Usage

Convert .srt content to .vtt:

// add namespace
use \Circlical\Subtitles\Subtitles;

(new Subtitles())->load($srtContent, 'srt')->content('vtt');

Manually create 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'));

Load subtitles from string

$string = "
1
00:02:17,440 --> 00:02:20,375
Senator, we're making our final approach
";  

$subtitles = Subtitles::load($string, 'srt');

Get file content without saving to file

echo $subtitles->content('vtt');

Add subtitles

$subtitles->add(0, 5, 'some text'); // from 0, till 5 seconds  

// Add multiline text
$subtitles->add(0, 5, [
    'first line',
    'second line',
]);

Remove subtitles

$subtitles->remove(0, 5); // from 0, till 5 seconds

Add 1 second to all subtitles

$subtitles->shiftTime(1);

Subtract 0.5 second

$subtitles->shiftTime(-0.5);

Add 5 second to subtitles starting from 1 minute till 2 mintes

$subtitles->shiftTime(5, 60, 120);

Example: shift time gradually by 2 seconds over 1 hour video. At the beginning of the video don't change time, in the middle shift time by 1 second. By the end of video, shift time by 2 seconds.

$subtitles->shiftTimeGradually(2, 0, 3600);

"Internal Format"

"Internal Format" is just a PHP array. It is used internally in library to be able to convert between different formats.

Array
(
    [0] => Array
        (
            [start] => 137.44
            [end] => 140.375
            [lines] => Array
                (
                    [0] => Senator, we're making
                    [1] => our final approach into Coruscant.
                )
        )
    [1] => Array
        (
            [start] => 140.476
            [end] => 142.501
            [lines] => Array
                (
                    [0] => Very good, Lieutenant.
                )
        )
)
[start] - when to start showing text (float - seconds)
[end] - when to stop showing text (float -seconds)
[lines] - one or more text lines (array)

Running Tests

./vendor/bin/phpunit

Contribution

Not all original converters from the fork have been corrected. Feel free to convert one from the 'todo' folder and open a PR!

Report Bugs

If some file is not working with the library, please create and issue and attach the file.

saeven/subtitles 适用场景与选型建议

saeven/subtitles 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.5k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 saeven/subtitles 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 saeven/subtitles 我们能提供哪些服务?
定制开发 / 二次开发

基于 saeven/subtitles 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 50
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-04-10