forked from HeiSir2014/M3U8-Downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpegTest.js
55 lines (47 loc) · 1.54 KB
/
ffmpegTest.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
"use strict";
const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');
const { Readable} = require('stream');
const path = require('path');
const got = require('got');
const { default: async } = require('async');
const ffmpegPath = require('ffmpeg-static');
(async ()=>{
var respose = await got("https://tools.heisir.cn/HLSDownload/ChromeVideoPlugin.crx",{responseType:"buffer"});
console.log(respose.headers['content-length'])
console.log(respose.body.length)
console.log(respose.error);
});
console.log(ffmpegPath)
/*
const dir = 'E:\\Project\\my_project\\M3U8-Downloader\\source\\download\\1592447619950\\';
let inputStream = new Readable();
let _ffmpeg = ffmpeg(inputStream)
.setFfmpegPath('E:\\Project\\my_project\\M3U8-Downloader\\source\\ffmpeg.exe')
.videoCodec('copy')
.audioCodec('copy')
.save("E:\\Project\\my_project\\M3U8-Downloader\\source\\download\\1592447619950\\output.mp4")
.on('progress', function(info) {
console.log(info);
})
.on('end', function() {
console.log('done processing input stream');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
});
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
fs.readdir(dir,function(err,files){
for (let index = 0; index < files.length; index++) {
const file = files[index];
if(file.endsWith(".ts"))
{
inputStream.push( fs.readFileSync(path.join(dir,file)) );
//console.log(`file : ${index}`);
}
}
inputStream.push(null);
});
*/