File: example.php

Recommend this page to a friend!
  Classes of Luciano Salvino  >  PHP Edit Subtitles Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Edit Subtitles Class
Edit video subtitles in SRT and VTT formats
Author: By
Last change: New convert from SRT to VTT format
Date: 3 years ago
Size: 1,103 bytes
 

Contents

Class file image Download
<?php

include('phpEditSubtitles.php');

$st = new phpEditSubtitles();

$st->setFile('test.srt');
// set output type to vtt (it will convert from srt to vtt type)
$st->setType('vtt');
$st->readFile();

// Edit subtitle on position 23
// IMPORTANT: it will reordenate the time. If the amount of time is smaller than $timeIni or bigger than $timeEnd the request will not be processed
$order = 23;
$timeIni = '00:01:10,880';
$timeEnd = '00:01:18,830';
$subtitle = 'Edit subtitle';
$st->editSubtitle($order,$timeIni,$timeEnd,$subtitle);

// remove subtitle on position 25
$st->deleteSubtitle(25);

// add subtitle on position 25
// IMPORTANT: it will reordenate the time. If the amount of time is smaller than $timeIni or bigger than $timeEnd the request will not be processed
$order = 25;
$timeIni = '00:01:31,010';
$timeEnd = '00:01:32,790';
$subtitle = 'New subtitle';
$st->addSubtitle($order,$timeIni,$timeEnd,$subtitle);

// save subtitles in a new file
$st->saveFile('newfile');

// get array of subtitles
$subtitles = $st->getSubtitles();

echo
'<pre>';
print_r($subtitles);
echo
'</pre>';


For more information send a message to info at phpclasses dot org.