|
| 1 | +First, we breakdown the video into frames. |
| 2 | +``` bash |
| 3 | +ffmpeg -i asd.mp4 -vf "crop=900:860" frame%04d.png |
| 4 | +``` |
| 5 | + |
| 6 | +Then we console log the arrays after all of the calculations have been done. |
| 7 | + |
| 8 | +Note that you need to set the frame count in the for loop. |
| 9 | +``` html |
| 10 | +<script type="text/javascript"> |
| 11 | + let rickrollpc = [] |
| 12 | + let rickrollphone = [] |
| 13 | + // Function to pad numbers with leading zeros |
| 14 | + function padNumber(num, length) { |
| 15 | + let str = num.toString(); |
| 16 | + while (str.length < length) { |
| 17 | + str = '0' + str; |
| 18 | + } |
| 19 | + return str; |
| 20 | + } |
| 21 | + for (let i = 1; i <= 54; i++) { |
| 22 | + let frameNumber = padNumber(i, 4); |
| 23 | + let filename = `./videos/frame${frameNumber}.png`; |
| 24 | + aalib.read.image.fromURL(filename) |
| 25 | + .map(aalib.aa({ width: 90, height: 40})) |
| 26 | + .map(aalib.filter.inverse(true)) |
| 27 | + .map(aalib.render.html({ background: "#fff", fontFamily: "Ubuntu Mono, monospace", charset: "$1234567890{;:}(){}#$&*_+=-" })) |
| 28 | + .do(function (el) { |
| 29 | + |
| 30 | + rickrollpc[i-1] = el.innerText.split("\n"); |
| 31 | + }) |
| 32 | + .subscribe() |
| 33 | + aalib.read.image.fromURL(filename) |
| 34 | + .map(aalib.aa({ width: 40, height: 25})) |
| 35 | + .map(aalib.filter.inverse(true)) |
| 36 | + .map(aalib.render.html({ background: "#fff", fontFamily: "Ubuntu Mono, monospace", charset: "$1234567890{;:}(){}#$&*_+=-" })) |
| 37 | + .do(function (el) { |
| 38 | + |
| 39 | + rickrollphone[i-1] = el.innerText.split("\n"); |
| 40 | + }) |
| 41 | + .subscribe() |
| 42 | + } |
| 43 | + setInterval(() => { |
| 44 | + console.log('PC') |
| 45 | + console.log(rickrollpc) |
| 46 | + console.log('Phone') |
| 47 | + console.log(rickrollphone) |
| 48 | + },2500) |
| 49 | +</script> |
| 50 | +``` |
| 51 | +Afterwards, paste the Pre-Rendered AA animations as an array in your code. |
0 commit comments