diff options
author | Minteck <contact@minteck.org> | 2022-04-08 14:33:28 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-04-08 14:33:28 +0200 |
commit | 1f3516f4d7a4ce1ccff7d17b65af5cf0eb0a60d3 (patch) | |
tree | e01f3442ac1c453735a9e7a4e46edb3bf5648d38 | |
parent | 0ce1dfec2f5df4c919c2004ed05584ad99090afe (diff) | |
download | argon-transcode-1f3516f4d7a4ce1ccff7d17b65af5cf0eb0a60d3.tar.gz argon-transcode-1f3516f4d7a4ce1ccff7d17b65af5cf0eb0a60d3.tar.bz2 argon-transcode-1f3516f4d7a4ce1ccff7d17b65af5cf0eb0a60d3.zip |
Working!
-rw-r--r-- | .DS_Store | bin | 0 -> 10244 bytes | |||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .idea/.gitignore | 5 | ||||
-rw-r--r-- | .idea/ArgonTranscoder.iml | 12 | ||||
-rw-r--r-- | .idea/deployment.xml | 14 | ||||
-rw-r--r-- | .idea/jsLibraryMappings.xml | 6 | ||||
-rw-r--r-- | .idea/modules.xml | 8 | ||||
-rw-r--r-- | .idea/vcs.xml | 6 | ||||
-rw-r--r-- | index.js | 30 |
9 files changed, 83 insertions, 0 deletions
diff --git a/.DS_Store b/.DS_Store Binary files differnew file mode 100644 index 0000000..48e965a --- /dev/null +++ b/.DS_Store diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b30601 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +source +output
\ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/ArgonTranscoder.iml b/.idea/ArgonTranscoder.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/ArgonTranscoder.iml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="WEB_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/temp" /> + <excludeFolder url="file://$MODULE_DIR$/.tmp" /> + <excludeFolder url="file://$MODULE_DIR$/tmp" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module>
\ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..6810dd8 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="PublishConfigData" serverName="Minteck" remoteFilesAllowedToDisappearOnAutoupload="false"> + <serverData> + <paths name="Minteck"> + <serverdata> + <mappings> + <mapping deploy="/mnt/argon-cdn/files" local="$PROJECT_DIR$/output" web="/" /> + </mappings> + </serverdata> + </paths> + </serverData> + </component> +</project>
\ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..d23208f --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="JavaScriptLibraryMappings"> + <includedPredefinedLibrary name="Node.js Core" /> + </component> +</project>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9a852be --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/ArgonTranscoder.iml" filepath="$PROJECT_DIR$/.idea/ArgonTranscoder.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..5527ace --- /dev/null +++ b/index.js @@ -0,0 +1,30 @@ +const fs = require('fs'); +const crypto = require('crypto'); +const path = require('path'); +const child_process = require('child_process'); + +if (!fs.existsSync("./source")) fs.mkdirSync("./source"); +if (fs.existsSync("./output")) fs.rmSync("./output", { recursive: true }); +fs.mkdirSync("./output"); + +for (let file of fs.readdirSync("./source")) { + let id = crypto.createHash('sha1').update(fs.readFileSync("./source/" + file)).digest('hex'); + fs.mkdirSync("./output/" + id); + fs.copyFileSync("./source/" + file, "./output/" + id + "/original" + path.extname(file)); + let original = "./output/" + id + "/original" + path.extname(file) + + child_process.execFileSync("ffmpeg", [ "-i", original, "./output/" + id + "/original.flac" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "./output/" + id + "/originalpcm.wav" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-ab", "460k", "-acodec", "pcm_s32le", "-ar", "48000", "-sample_fmt", "s32", "./output/" + id + "/ultrahighpcm.wav" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-ab", "460k", "-ar", "48000", "-sample_fmt", "s32", "./output/" + id + "/ultrahigh.flac" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-ab", "320k", "-ar", "48000", "-sample_fmt", "s32p", "./output/" + id + "/veryhigh.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s32p", "-qscale:a", "0", "-ar", "48000", "./output/" + id + "/high.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s16p", "-qscale:a", "3", "-ar", "48000", "./output/" + id + "/medium.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s16p", "-qscale:a", "5", "-ar", "44100", "./output/" + id + "/low.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s16p", "-qscale:a", "7", "-ar", "32000", "./output/" + id + "/verylow.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s16p", "-qscale:a", "8", "-ar", "22050", "./output/" + id + "/ultralow.mp3" ], { stdio: 'inherit' }) + child_process.execFileSync("ffmpeg", [ "-i", original, "-sample_fmt", "s16p", "-qscale:a", "9", "-ac", "1", "-ar", "16000", "./output/" + id + "/superlow.mp3" ], { stdio: 'inherit' }) + fs.writeFileSync("./output/" + id + "/original.txt", file); + + fs.unlinkSync(original); +}
\ No newline at end of file |