linuxify ffmpeg

This commit is contained in:
Djkáťo 2023-12-27 18:47:54 +01:00
parent 83c5a79d81
commit b57321350d
3 changed files with 158 additions and 158 deletions

View file

@ -7,12 +7,13 @@ export function generate_db() {
let db = new DB let db = new DB
let collections: string[] = new Array() let collections: string[] = new Array()
let new_songs = [] let new_songs = []
const path_char = songs[0].includes("\\") ? "\\" : "/"
//create collections by folder names //create collections by folder names
for (let i = 0; i < songs.length; i++) { for (let i = 0; i < songs.length; i++) {
const song = songs[i] const song = songs[i]
const last_i = song.lastIndexOf("\\") const last_i = song.lastIndexOf(path_char)
const collection_name = song.slice(song.slice(0, last_i).lastIndexOf("\\") + 1, last_i) const collection_name = song.slice(song.slice(0, last_i).lastIndexOf(path_char) + 1, last_i)
/* /*
const foreforelast_i = song.slice(0, forelast_i - 1) const foreforelast_i = song.slice(0, forelast_i - 1)
const foreforeforelast_i = song.slice(0, foreforelast_i - 1).lastIndexOf("\\") const foreforeforelast_i = song.slice(0, foreforelast_i - 1).lastIndexOf("\\")
@ -35,10 +36,10 @@ export function generate_db() {
//create songs //create songs
for (let i = 0; i < new_songs.length; i++) { for (let i = 0; i < new_songs.length; i++) {
let song = new_songs[i] let song = new_songs[i]
const last_i = song.song.lastIndexOf("\\") const last_i = song.song.lastIndexOf(path_char)
const name = song.song.slice(last_i + 1) const name = song.song.slice(last_i + 1)
const song_url = song.song.slice(song.song.indexOf("public\\") + 7) const song_url = song.song.slice(song.song.indexOf(`public${path_char}`) + 7)
const db_song = new Song({ const db_song = new Song({
name: name.slice(0, name.lastIndexOf(".")), name: name.slice(0, name.lastIndexOf(".")),
artists: [], artists: [],

View file

@ -12,7 +12,7 @@ function generate_new_photo_sizes(file, currentExtention) {
const path = file.substring(0, file.lastIndexOf("\\")) const path = file.substring(0, file.lastIndexOf("\\"))
file = file.substring(file.lastIndexOf("\\") + 1) file = file.substring(file.lastIndexOf("\\") + 1)
let command = "" let command = ""
command += `cd "${path}" && start cmd /k "` command += `cd "${path}" && konsole -e "`
command += `ffmpeg -y -i "${file}.${currentExtention}" -lossless 0 -quality 90 -compression_level 6 "${file}_ogw.webp" ` command += `ffmpeg -y -i "${file}.${currentExtention}" -lossless 0 -quality 90 -compression_level 6 "${file}_ogw.webp" `
command += ` -vf scale=1000:-1 -lossless 0 -quality 90 -compression_level 6 "${file}_1000p.webp"` command += ` -vf scale=1000:-1 -lossless 0 -quality 90 -compression_level 6 "${file}_1000p.webp"`
command += ` -vf scale=800:-1 -lossless 0 -quality 90 -compression_level 6 "${file}_800p.webp"` command += ` -vf scale=800:-1 -lossless 0 -quality 90 -compression_level 6 "${file}_800p.webp"`
@ -30,28 +30,27 @@ function generate_new_sounds_ogg(file, currentExtention) {
file = file.substring(file.lastIndexOf("\\") + 1) file = file.substring(file.lastIndexOf("\\") + 1)
let command = "" let command = ""
command += `cd "${path}" && start cmd /k "` command += `konsole -e "`
command += `ffmpeg -y -i "${file}.${currentExtention}" ` command += `ffmpeg -y -i '${file}.${currentExtention}' `
//Adds 25ms of delay to all samples //Adds 25ms of delay to all samples
command += `-af "adelay=25:all=true" ` command += `-af 'adelay=25:all=true' `
//So the demo is HQ //So the demo is HQ
if (file.includes("Luna Lenta")) command += `-c:a libopus -b:a 256k "${file}.ogg"` if (file.includes("demo")) command += `-c:a libopus -b:a 256k '${file}.ogg'"`
else command += `-c:a libopus -b:a 96k "${file}.ogg"` else command += `-c:a libopus -b:a 96k '${file}.ogg'"`
command += ` && exit"`
exec(command) exec(command)
// console.log(command) console.log(command)
} }
function generate_new_sounds_mp3(file, currentExtention) { function generate_new_sounds_mp3(file, currentExtention) {
const path = file.substring(0, file.lastIndexOf("\\")) const path = file.substring(0, file.lastIndexOf("\\"))
file = file.substring(file.lastIndexOf("\\") + 1) file = file.substring(file.lastIndexOf("\\") + 1)
let command = "" let command = ""
command += `cd "${path}" && start cmd /k "` command += `konsole -e "`
command += `ffmpeg -y -i "${file}.${currentExtention}" ` command += `ffmpeg -y -i '${file}.${currentExtention}' `
//Adds 25ms of delay to all samples //Adds 25ms of delay to all samples
command += `-af "adelay=25:all=true" ` command += `-af 'adelay=25:all=true' `
command += `-b:a 160k "${file}.mp3"` if (file.includes("demo")) command += `-b:a 256k '${file}.mp3'"`
command += ` && exit"` else command += `-b:a 160k '${file}.mp3'"`
exec(command) exec(command)
// console.log(command) // console.log(command)
} }
@ -69,7 +68,7 @@ function generate_new_video_sizes_mp4(file, currentExtention, width_resolutions)
exec(command).once("exit", () => { exec(command).once("exit", () => {
for (const resolution of width_resolutions) { for (const resolution of width_resolutions) {
let res_command = "" let res_command = ""
res_command += `start cmd /k "` res_command += `konsole -e "`
res_command += `cd "${path}" && ` res_command += `cd "${path}" && `
res_command += `ffmpeg -y -i "${file}.${currentExtention}" ` res_command += `ffmpeg -y -i "${file}.${currentExtention}" `
res_command += `-vcodec libx264 -g 240 -b:v 3M -vf scale=${resolution}:-2 -pass 2 "${file}_${resolution}p.mp4"` res_command += `-vcodec libx264 -g 240 -b:v 3M -vf scale=${resolution}:-2 -pass 2 "${file}_${resolution}p.mp4"`
@ -92,7 +91,7 @@ function generate_new_video_sizes_webm(file, currentExtention, width_resolutions
exec(command).once("exit", () => { exec(command).once("exit", () => {
for (const resolution of width_resolutions) { for (const resolution of width_resolutions) {
let res_command = "" let res_command = ""
res_command += `start cmd /k "` res_command += `konsole -e "`
res_command += `cd "${path}" && ` res_command += `cd "${path}" && `
res_command += `ffmpeg -y -i "${file}.${currentExtention}" ` res_command += `ffmpeg -y -i "${file}.${currentExtention}" `
res_command += `-vcodec libvpx-vp9 -cpu-used 0 -deadline good -quality good -g 240 -vf scale=${resolution}:-1 -crf 42 -b:v 0 -c:a libopus -row-mt 1 -tile-rows 2 -tile-columns 4 -threads 16 -auto-alt-ref 6 -pass 2 "${file}_${resolution}p.webm"` res_command += `-vcodec libvpx-vp9 -cpu-used 0 -deadline good -quality good -g 240 -vf scale=${resolution}:-1 -crf 42 -b:v 0 -c:a libopus -row-mt 1 -tile-rows 2 -tile-columns 4 -threads 16 -auto-alt-ref 6 -pass 2 "${file}_${resolution}p.webm"`
@ -102,7 +101,7 @@ function generate_new_video_sizes_webm(file, currentExtention, width_resolutions
}) })
} }
let dirs = filehound.create() let dirs = filehound.create()
.path("../public/media") .path("../public")
.directory() .directory()
.findSync() .findSync()
console.log(dirs) console.log(dirs)
@ -121,14 +120,14 @@ for (let i = 0; i < dirs.length; i++) {
} }
for (let current_media of current_folder_files) { for (let current_media of current_folder_files) {
current_media = [current_media.substring(0, current_media.lastIndexOf(".")), current_media.substring(current_media.lastIndexOf(".") + 1)] current_media = [current_media.substring(0, current_media.lastIndexOf(".")), current_media.substring(current_media.lastIndexOf(".") + 1)]
if (current_media[1] == "wav" || current_media[1] == "mp3") { if (current_media[1] == "wav") {
console.log(`${current_media[0]}.${current_media[1]}\n`) console.log(`${current_media[0]}.${current_media[1]}\n`)
generate_new_sounds_ogg(`${current_media[0]}`, `${current_media[1]}`) generate_new_sounds_ogg(`${current_media[0]}`, `${current_media[1]}`)
if (current_media[1] == "mp3") continue
generate_new_sounds_mp3(`${current_media[0]}`, `${current_media[1]}`) generate_new_sounds_mp3(`${current_media[0]}`, `${current_media[1]}`)
} }
/*
if (current_media[1] == "webm" || current_media[1] == "mov" || current_media[1] == "avi" || current_media[1] == "mp4") { if (current_media[1] == "webm" || current_media[1] == "mov" || current_media[1] == "avi" || current_media[1] == "mp4") {
if (/\_\d*p/.test(current_media[0])) continue if (/\_\d*p/.test(current_media[0])) continue
// console.log(`Video: ${current_media[0]}.${current_media[1]}\n`) // console.log(`Video: ${current_media[0]}.${current_media[1]}\n`)
@ -144,7 +143,7 @@ for (let i = 0; i < dirs.length; i++) {
console.log(`.\\${current_media[0]}.${current_media[1]}\n`) console.log(`.\\${current_media[0]}.${current_media[1]}\n`)
generate_new_anim_photo_sizes(`.\\${current_media[0]}`, `${current_media[1]}`) generate_new_anim_photo_sizes(`.\\${current_media[0]}`, `${current_media[1]}`)
} }*/
} }
} }
} }

View file

@ -1 +1 @@
export const songs = ["..\\public\\samples\\bass\\01 HTS Arp Bass.ogg","..\\public\\samples\\bass\\02 HTS Hard Bass.ogg","..\\public\\samples\\bass\\03 HTS Break Bass.ogg","..\\public\\samples\\bass\\04 HTS Sub Bass.ogg","..\\public\\samples\\demos\\Demo by Luna Lenta and Nuphory.ogg","..\\public\\samples\\drums\\01 HTS Rides and Hats.ogg","..\\public\\samples\\drums\\02 HTS Claps and Hats.ogg","..\\public\\samples\\drums\\03 HTS Club Snares.ogg","..\\public\\samples\\drums\\04 HTS Buildup Snares.ogg","..\\public\\samples\\FX\\01 HTS Boom Kicks.ogg","..\\public\\samples\\FX\\02 HTS Verbclaps.ogg","..\\public\\samples\\FX\\03 HTS Noisesweep.ogg","..\\public\\samples\\FX\\04 HTS Combined FX.ogg","..\\public\\samples\\kicks\\01 HTS Trancekick.ogg","..\\public\\samples\\kicks\\02 HTS Sizzle Layer.ogg","..\\public\\samples\\kicks\\03 HTS Transients.ogg","..\\public\\samples\\kicks\\04 HTS Kick Combined.ogg","..\\public\\samples\\loops\\01 HTS Loop CH.ogg","..\\public\\samples\\loops\\02 HTS Loop OH.ogg","..\\public\\samples\\loops\\03 HTS Perc Loop.ogg","..\\public\\samples\\loops\\04 HTS Full Loop.ogg","..\\public\\samples\\synths\\01 HTS Leads and Bass 01.ogg","..\\public\\samples\\synths\\02 HTS Leads and Pads 01.ogg","..\\public\\samples\\synths\\03 HTS Leads and Bass 02.ogg","..\\public\\samples\\synths\\04 HTS Leads and Pads 02.ogg"] export const songs = ["../public/samples/FX/01 HTS Boom Kicks.ogg","../public/samples/FX/02 HTS Verbclaps.ogg","../public/samples/FX/03 HTS Noisesweep.ogg","../public/samples/FX/04 HTS Combined FX.ogg","../public/samples/bass/01 HTS Arp Bass.ogg","../public/samples/bass/02 HTS Hard Bass.ogg","../public/samples/bass/03 HTS Break Bass.ogg","../public/samples/bass/04 HTS Sub Bass.ogg","../public/samples/demos/01 demo 1 - Violet Delta & Eyhz.ogg","../public/samples/demos/02 demo 2 - Walras.ogg","../public/samples/demos/03 demo 3 - G4TE-16.ogg","../public/samples/demos/04 demo 4 - shadeux.ogg","../public/samples/demos/05 demo 5 - crowit.ogg","../public/samples/demos/06 demo 6 - sh0wtime.ogg","../public/samples/demos/07 demo 7 - nuphory & Luna Lenta.ogg","../public/samples/drums/01 HTS Rides and Hats.ogg","../public/samples/drums/02 HTS Claps and Hats.ogg","../public/samples/drums/03 HTS Club Snares.ogg","../public/samples/drums/04 HTS Buildup Snares.ogg","../public/samples/kicks/01 HTS Trancekick.ogg","../public/samples/kicks/02 HTS Sizzle Layer.ogg","../public/samples/kicks/03 HTS Transients.ogg","../public/samples/kicks/04 HTS Kick Combined.ogg","../public/samples/loops/01 HTS Loop CH.ogg","../public/samples/loops/02 HTS Loop OH.ogg","../public/samples/loops/03 HTS Perc Loop.ogg","../public/samples/loops/04 HTS Full Loop.ogg","../public/samples/synths/01 HTS Leads and Bass 01.ogg","../public/samples/synths/02 HTS Leads and Pads 01.ogg","../public/samples/synths/03 HTS Leads and Bass 02.ogg","../public/samples/synths/04 HTS Leads and Pads 02.ogg"]