mantas-done / subtitles

Subtitle/caption converter
https://gotranscript.com/subtitle-converter
MIT License
142 stars 48 forks source link

How create manual .vtt file with sub title positions #53

Closed lokeshmukeriya closed 1 year ago

lokeshmukeriya commented 1 year ago

$subtitles->add() except only 3 arguments startTime,andTime, and titileText. I want to create file like this

00:11.000 --> 00:13.000 line:90% align:left position:10%
<v Roger Bingham>We are in New York City

00:13.000 --> 00:16.000 line:90% align:center position:50%
<v Roger Bingham>We’re actually at the Lucern Hotel, just down the street
kocoten1992 commented 1 year ago

(I can only speak for .vtt) the current implementation only handle time and do not handle anything else, so probably not possible..

lokeshmukeriya commented 1 year ago

Also, Load subtitles from a string do not work for me I have tried the code below.

$vttSubtitle ="";
foreach ($param['captions'] as $caption) {
    $vttSubtitle .= "$caption->startTime / 1000 --> $caption->endTime $caption->mediaPosition\n$caption->$textColumn\n\n";
}
$subtitles = Subtitles::load($vttSubtitle, 'vtt');
$data = $subtitles->content('vtt');
mantas-done commented 1 year ago

Now styles can be added. $subtitles->add(0, 5, 'text', ['vtt_cue_settings' => 'position:50% line:15% align:middle']);