我正试图让这个srt到vtt转换器工作,但它在尝试时一直说"无法检测文件编码",这是我的代码。
require('src/SrtParser/srtFile.php');
if(isset($_POST['convert'])){
try{
$file = new 'SrtParser'srtFile('./subtitle.srt');
// display the text of the first entry
echo $file->getSub(0)->getText();
$file->mergeSrtFile($file2);
$file->build();
$file->save('./new_subtitles.vtt');
}
catch(Exception $e){
echo 'Error: '.$e->getMessage()."'n";
}
}
有人能告诉我我做错了什么吗?文件链接正确。
链接到GitHub上的文件解析器delphiki/SubRip文件解析器
我建议在Notepad++中打开文件并将编码转换为UTF-8。
或者你可以使用:
Subtitles::convert('subtitles.srt', 'new_subtitles.vtt');
https://github.com/mantas-done/subtitles