Last active
January 20, 2025 20:16
-
-
Save FoxxMD/91cc13b53dfcc9e21f3f918c88fe3a7c to your computer and use it in GitHub Desktop.
convert acc-adts (audio/x-hx-aac-adts) audio to plain AAC with ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const {execSync} = require('child_process'); | |
const files = fs.readdirSync('.'); | |
for(const f of files) { | |
const info = path.parse(f); | |
if(info.ext !== '.aac') { | |
console.log(`Skipping non AAC file ${f}`); | |
continue; | |
} | |
if(files.some(x => x.includes(`${info.name}.m4a`))) { | |
console.log(`Skipping already converted file ${f}`); | |
continue; | |
} | |
const cmd = `ffmpeg -fflags +discardcorrupt -i "${info.name}${info.ext}" -bsf:a aac_adtstoasc -c:a copy "${info.name}.m4a"`; | |
console.log(cmd); | |
try { | |
execSync(cmd, { stdio: ['ignore','inherit','inherit'] }); | |
} catch (e) { | |
console.error(e); | |
console.error(`Removing ${info.name}.m4a`); | |
fs.unlinkSync(`${info.name}.m4a`); | |
} | |
} | |
console.log('Done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment