update name splicing and audio encoding
This commit is contained in:
parent
9641ddb96d
commit
ef1f48efa4
4 changed files with 18 additions and 29 deletions
29
README.md
29
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!
|
# 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)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
How to install(Windows, Linux, MacOS):
|
How to install(Windows, Linux, MacOS):
|
||||||
1. get node.js from [here](https://nodejs.org)
|
1. get node.js from [here](https://nodejs.org)
|
||||||
2. get ffmpeg for your platform [here](https://ffmpeg.org/download.html), put into $PATH
|
2. get ffmpeg for your platform [here](https://ffmpeg.org/download.html), put into $PATH
|
||||||
3. run `npm install -g 8mb`
|
3. run `npm install -g 8mb` in your favourite terminal
|
||||||
4. execute anywhere using the `8mb [optional: -preset {preset Index}] [file1] [file2] . . .` command!
|
4. execute anywhere using the `8mb [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
|
|
||||||
|
|
||||||
|
|
||||||
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
|
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
|
|
@ -31,10 +31,12 @@ for (let i = 0; i < inputList.length; i++) {
|
||||||
|
|
||||||
file = file.split("\\")
|
file = file.split("\\")
|
||||||
file = file[file.length - 1]
|
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])
|
fileTypes.push(file_type)
|
||||||
fileNames.push(file[0])
|
fileNames.push(file_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -30,12 +30,14 @@ class Encoder {
|
||||||
*/
|
*/
|
||||||
async encodeAudio(path, out) {
|
async encodeAudio(path, out) {
|
||||||
let [duration, resolution] = await this.#getDurationAndResolution(path)
|
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) {
|
if (audioBitRate > this.#maxOpusBitrate) {
|
||||||
audioBitRate = this.#maxOpusBitrate
|
audioBitRate = this.#maxOpusBitrate
|
||||||
}
|
}
|
||||||
this.encoder = exec(`ffmpeg -y -i "${path}" -c:a libvorbis -b:a ${audioBitRate}k "${out}.ogg"`)
|
else if (audioBitRate < this.#minOpusBitrate) {
|
||||||
console.log(`ffmpeg -y -i "${path}" -c:a libvorbis -b:a ${audioBitRate}k "${out}.ogg"`)
|
audioBitRate = this.#minOpusBitrate
|
||||||
|
}
|
||||||
|
this.encoder = exec(`ffmpeg -y -i "${path}" -c:a libopus -b:a ${audioBitRate}k "${out}.ogg"`)
|
||||||
return [duration, out, undefined]
|
return [duration, out, undefined]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "8mb",
|
"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",
|
"description": "helps free discord users to send any media(image, video, audio) and not get limited by discords 8mb file limit",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in a new issue