12 lines
401 B
JavaScript
12 lines
401 B
JavaScript
import fs from 'fs'
|
|
import exec from './exec.js'
|
|
|
|
export default async function convertToMp3(filename) {
|
|
let newFilename = filename.split('.').slice(0, -1).join('.')+'.mp3'
|
|
if (!fs.existsSync(newFilename)) {
|
|
console.log('Converting input to mp3.')
|
|
await exec(`ffmpeg -y -i "${filename}" "${newFilename}"`)
|
|
console.log('Converted to mp3.')
|
|
}
|
|
return newFilename
|
|
} |