-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetect.js
More file actions
70 lines (63 loc) · 2.82 KB
/
detect.js
File metadata and controls
70 lines (63 loc) · 2.82 KB
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
70
const threshold = 130
const ffmpeg = require('fluent-ffmpeg')
const PNG = require('pngjs').PNG;
const fs = require('fs')
const path = require('path')
function strgen(){
let str = ''
const chars = 'abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ0123456789'
for(let i = 0;i<10;i++) str += chars[Math.floor(Math.random()*chars.length)]
return str
}
const tonescale = `...,,,,,,,`.split('')
const possibilities = [256,230,220,200,180,160,140,130,120,100].reverse()
let basestr = ''
const ss = strgen()
console.log('Preparing video...')
const ff = new ffmpeg(path.resolve(__dirname,`./input.mp4`))
ff.noAudio()
ff.size('16x9')
ff.fps(20)
//ff.format('mp4')
ff.addOptions(['-crf 18','-hide_banner'])
ff.save(path.resolve(__dirname,`./ohlord/temp_${ss}_%d.png`))
ff.on('end', async()=>{
console.log('Converting video frames...')
const f = (await fs.promises.readdir(path.join(__dirname,'ohlord'))).filter(f=>{
return f.endsWith('.png') && f.startsWith(`temp_${ss}`)
})
for(let i = 0;i<f.length;i++){
let filez = path.resolve(__dirname,'ohlord/temp_'+ss+'_'+(i+1)+'.png')
await new Promise((res,err)=>{
let thing = ""
fs.createReadStream(filez)
.pipe(new PNG())
.on('parsed', function() {
for (let y = 0; y < this.height; y++) {
for (let x = 0; x < this.width; x++) {
let idx = (this.width * y + x) << 2; // (black - white / 0 - 255)(directly taken from the docs lmao)
let idx2 = (this.width * y + (x+1)) << 2
let idx3 = (this.width * (y+1) + x) << 2
//could this be considered edge detection? maybe
if(Math.abs(((this.data[idx]+this.data[idx+1]+this.data[idx+2])/3)-(this.data[idx2]+this.data[idx2+1]+this.data[idx2+2])/3) > threshold || ((this.data[idx]+this.data[idx+1]+this.data[idx+2])/3)-((this.data[idx3]+this.data[idx3+1]+this.data[idx3+2])/3) > threshold){
thing += '1'
} else {
thing += '0'
}
}
thing += '|'
}
basestr += thing + ';'
res()
})
.on('error',e=>err(e))
})
}
fs.writeFileSync(path.resolve(__dirname,`./videodatae.txt`),basestr)
//if(err) return console.log('uploader error: ' + err) //{files:[{attachment:path.resolve(__dirname,`./ohlord/temp_${ss}.zip`),name:'generatedvideo.zip'}]}
console.log('extract the text file to the exploit\'s workspace folder before executing the script')
fs.unlink(path.resolve(__dirname,`./ohlord/temp_${ss}.zip`),()=>{})
for(const file of f){
fs.unlink(path.resolve(__dirname,`./ohlord/${file}`),()=>{})
}
});