diff --git a/README.md b/README.md index f99c238..0f23346 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,18 @@ -For all those who want to post memes that are just too big and surpass the 8mb free upload limit on discord, this is the app for you! # Automatically converts any video into webm, makes sure its 8mb or less! +For all those who want to post memes that are just too big and surpass the 8mb free upload limit on discord, this is the app for you! +This program outputs to following formats: + - audio codec: opus .ogg + - video codec: vp9 + opus .webm + - image codec: vp8 .webp (for gifs too) ![multiencoding](https://user-images.githubusercontent.com/25299243/166849422-5a687ec5-c110-4de9-bbc3-1ded54bbeaa8.gif) -![cmd_7he2xYV2XK](https://user-images.githubusercontent.com/25299243/166849534-482cd9f0-6a57-4454-bbca-813167cb9ac2.gif) - - How to install(Windows, Linux, MacOS): 1. get node.js from [here](https://nodejs.org) 2. get ffmpeg for your platform [here](https://ffmpeg.org/download.html), put into $PATH -3. run `npm install -g 8mb` -4. execute anywhere using the `8mb [optional: -preset {preset Index}] [file1] [file2] . . .` command! - -*Known issues:* - - videos with huge resolution (1080p+) and high framerate struggle to encode under 8mb even if less than a few minutes long - - really long videos fail to get under 8mb - - - - - ->*NOT WORKING RN, TERMKIT REFUSES TO COMPILE* ->How to install(Windows with binaries): ->1. make a folder in `C:\Program Files` called "DMC", put release binaries and [ffmpeg windows full-build executables](https://github.com/GyanD/codexffmpeg/releases/) into `C:\Program Files\DMC\` ->2. Add ffmpeg to PATH: `[Win BTN] + R`, type `SystemPropertiesAdvanced`, click `Environment Variables`, under "User variables for (user)" find variable Path, click on it and edit, in the now open window click `new`, and paste `C:\Program Files\DMC\`. ->3. If the command `ffmpeg` in cmd works, you can now drag and drop files onto the binary and have it work! ->4. to set performance preset, doubleclick the binary - +3. run `npm install -g 8mb` in your favourite terminal +4. execute anywhere using the `8mb [file1] [file2] . . .` command! For an amazing read on how to optimize vp9 for file sizes I reccomend this read: https://codeberg.org/deterenkelt/Nadeshiko/wiki/Researches%E2%80%89%E2%80%93%E2%80%89VP9-and-overshooting \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index c4c2b98..36a6855 100644 --- a/bin/index.js +++ b/bin/index.js @@ -31,10 +31,12 @@ for (let i = 0; i < inputList.length; i++) { file = file.split("\\") file = file[file.length - 1] - file = file.split(".") + const dot_index = file.lastIndexOf(".") + const file_name = file.slice(0, dot_index) + const file_type = file.slice(dot_index + 1) - fileTypes.push(file[file.length - 1]) - fileNames.push(file[0]) + fileTypes.push(file_type) + fileNames.push(file_name) } main() diff --git a/lib/encoder.js b/lib/encoder.js index c077702..ac3c5dd 100644 --- a/lib/encoder.js +++ b/lib/encoder.js @@ -30,12 +30,14 @@ class Encoder { */ async encodeAudio(path, out) { let [duration, resolution] = await this.#getDurationAndResolution(path) - let audioBitRate = Math.round(this.settings.size_limit / duration) + let audioBitRate = Math.round(this.settings.size_limit / duration * 0.95) if (audioBitRate > this.#maxOpusBitrate) { audioBitRate = this.#maxOpusBitrate } - this.encoder = exec(`ffmpeg -y -i "${path}" -c:a libvorbis -b:a ${audioBitRate}k "${out}.ogg"`) - console.log(`ffmpeg -y -i "${path}" -c:a libvorbis -b:a ${audioBitRate}k "${out}.ogg"`) + else if (audioBitRate < this.#minOpusBitrate) { + audioBitRate = this.#minOpusBitrate + } + this.encoder = exec(`ffmpeg -y -i "${path}" -c:a libopus -b:a ${audioBitRate}k "${out}.ogg"`) return [duration, out, undefined] } diff --git a/package.json b/package.json index 9b42946..b4856f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "8mb", - "version": "1.1.3", + "version": "1.1.4", "description": "helps free discord users to send any media(image, video, audio) and not get limited by discords 8mb file limit", "main": "index.js", "repository": {