forked from mayeaux/generate-subtitles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
srtToVtt.js
69 lines (50 loc) · 1.49 KB
/
srtToVtt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var fs = require('fs-extra')
var convert = require('cyrillic-to-latin')
// const srt2vtt = Promise.promisifyAll(require('srt2vtt'));
const srt2vtt = require('srt2vtt')
const path = './public/translated.srt'
const filename = 'serbian';
l = console.log;
l(srt2vtt)
// function createTicket(ticket) {
// // 1 - Create a new Promise
// return new Promise(function (resolve, reject) {
// // 2 - Copy-paste your code inside this function
// client.tickets.create(ticket, function (err, req, result) {
// // 3 - in your async function's callback
// // replace return by reject (for the errors) and resolve (for the results)
// if (err) {
// reject(err);
// } else {
// resolve(JSON.stringify(result));
// }
// });
// });
// }
function converSrtToVtt(){
}
async function main(){
var data = await fs.readFile(path, 'utf8');
data = convert(data);
// l(data);
// data = await srt2vtt(data);
srt2vtt(data, async function(err, vttData) {
l('running here');
l(vttData);
// vttData = convert(vttData);
// l(vttData);
if (err) throw new Error(err);
l(data);
fs.writeFileSync(`./public/redone.vtt`, vttData);
});
// l(data);
// data = await convert(data);
// l(data);
// await fs.writeFile(data, `${path}/${filename}.mp4.vtt`, 'utf8')
}
main();
//
// fs.createReadStream(`${path}/${filename}.mp4.srt`)
// .pipe(srt2vtt())
// .pipe(convert())
// .pipe(fs.createWriteStream(`${path}/${filename}.mp4.vtt`))