-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMAIN_codeblock.js
More file actions
90 lines (83 loc) · 3.14 KB
/
MAIN_codeblock.js
File metadata and controls
90 lines (83 loc) · 3.14 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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 blocks = {
"▀":[1,0],
"▄":[0,1],
"█":[1,1],
" ":[0,0]
}*/
const blocks = {
"▀":[0,1],
"▄":[1,0],
"█":[0,0],
"░":[1,1]
}
/*const tonescale = `0000011111`.split('')
const possibilities = [256,230,220,200,180,160,140,130,120,100].reverse()*/
let basestr = ''
function eq(a, b) {
if (a === b) return true;
if (a == null || b == null) return false;
if (a.length !== b.length) return false;
for (var i = 0; i < a.length; ++i) {
if (a[i] !== b[i]) return false;
}
return true;
}
const ss = strgen()
console.log('Preparing video...')
const ff = new ffmpeg(path.resolve(__dirname,`./input.mp4`))
ff.noAudio()
ff.size('13x7')
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}`)
})
const test = []
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=y+2) {
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+1) + x) << 2;
for(const [k,v] of Object.entries(blocks)){
if(eq(v,[
Number(!((this.data[idx]+this.data[idx+1]+this.data[idx+2])/3<170)),
Number(!((this.data[idx2]+this.data[idx2+1]+this.data[idx2+2])/3<170)),
])) thing += k
}
}
thing += '|'
}
basestr += thing + '\n'
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}`),()=>{})
}
});