Download the PHP package rodchyn/subtitles without Composer
On this page you can find all versions of the php package rodchyn/subtitles. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package subtitles
Caption And Subtitle Converter for PHP
Convert and edit subtitles and captions.
Supported formats
Format | Extension |
---|---|
SubRip | .srt |
WebVTT | .vtt |
Spruce Technologies SubTitles | .stl |
Youtube Subtitles | .sbv |
SubViewer | .sub |
Advanced Sub Station | .ass |
DFXP | .dfxp |
TTML | .ttml |
QuickTime | .qt.txt |
Installation
Usage
Convert .srt file to .vtt:
Manually create file
Load subtitles from existing file
Load subtitles from string
Save subtitles to file
Get file content without saving to file
Add subtitles `
Remove subtitles
Add 1 second to all subtitles
Subtract 0.5 second
Add 5 second to subtitles starting from 1 minute till 2 mintes
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.
How to add new subtitle format?
You need to implement ConverterContract.php interface. It has two methods.
Basically what your implementation should be able to do, is convert subtitle file to "internal library's format", and from internal library's format back to subtitle file.
"Internal library's" format is used like middle ground, to be able to convert between different formats.
Best example is to look how SrtConverter.php is implemented.
And this is example of .srt file.
"Internal Format"
"Internal Format" is just a PHP array. It is used internally in library to be able to convert between different formats.
Running Tests
Simplest way is to download and put phpunit.phar file into the main directory of the project. Then run the command:
Contribution
You can contribute in any way you want. If you need some guidance, choose something from this table:
Task | Difficulty | Description |
---|---|---|
Add new formats | Medium | Supporting more formats is nice. Some popular formats: .mcc, .cap |
Refactor StlConverter.php file | Easy | .stl format is very similar to .srt. The only problem is that StlConverter.php code can be simplified a lot (check SrtConverter.php as example) |
Add .scc format | Hard | Format description |
For now library should support only basic features (several lines of text). No need to support different text styles or positioning of text.
Report Bugs
If some file is not working with the library, please create and issue and attach the file.