UNPKG

@ibaraki-douji/anime4k

Version:

Upscale Videos using Anime4KCPP

91 lines (75 loc) 1.99 kB
# Anime4K A simple image upscaler using [anime-4k-cpp](https://github.com/TianZerL/Anime4KCPP) ## Getting started `npm i @ibaraki-douji/anime4k --save` ## Usage ### Import the lib ```js const anime4k = require('@ibaraki-douji/anime4k') ``` ### Start Upscale ```js const anime4k = require('@ibaraki-douji/anime4k') const input = "./path/to/image"; //const input = readFileSync('./path/to/image'); // <- Buffer const output = "./path/to/upscaled/image"; //const output = "" // <- IF BufferOutput Option const options = { /** * Threads * -t */ threads: 16, /** * Upscale Multiplier * -z */ scale: 2, /** * Choose GPU * -q */ gpu: true, outputAsBuffer: true } anime4k.upscale(input, output, options); ``` ### Wait the end ```js const anime4k = require('@ibaraki-douji/anime4k') const upscale = anime4k.upscale(input, output, options); upscale.finishedPromise().then(() => { console.log("Finished") }) ``` ### Get Buffer at End ```js const anime4k = require('@ibaraki-douji/anime4k') const upscale = anime4k.upscale(input, output, options); upscale.finishedPromise().then(() => { writeFileSync("./buffer.mp4", upscale.endBuffer); }) ``` ### List yours GPUs ```js const anime4k = require('@ibaraki-douji/anime4k') anime4k.listGPUs().then(console.log) ``` ## Exemple ```js const anime4k = require('@ibaraki-douji/anime4k') // npm i axios const axios = require('axios').default // MAKE A ASYNC FUNCTION AT START (async () => { const upscale = anime4k.upscale((await axios.get('https://cdn.discordapp.com/attachments/770019121349001227/874597329594892338/in.mp4')).data, "./output.mp4", { upscale: 2 }); await upscale.finishedPromise() console.log("Finished"); })() ``` ## More Help and Support Discord : https://discord.gg/mD9c4zP4Er # Ask me what you want in the Discord server