Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions download-third-party-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ async function fileExists(filePath) {
}

async function moveDirChildrenUpAndDeleteDir(dirName) {
if (!(await fileExists(dirName))) {
console.log(`Skipping move; directory does not exist: "${dirName}"`)
return
}

const parentDirName = path.resolve(path.join(dirName, '..'))
const fileNames = await fsPromises.readdir(dirName)
for (const fileName of fileNames) {
Expand Down Expand Up @@ -196,14 +201,22 @@ async function main() {
)

if (process.platform === 'win32') {
await moveDirChildrenUpAndDeleteDir(
path.join(
`${winOrMac}-extra-files`,
'ThirdPartyApps',
'ffmpeg',
'ffmpeg-8.0-essentials_build'
)
const ffmpegParentDir = path.join(`${winOrMac}-extra-files`, 'ThirdPartyApps', 'ffmpeg')
const ffmpegDirChildren = await fsPromises.readdir(ffmpegParentDir, {
withFileTypes: true,
})
const extractedFfmpegDir = ffmpegDirChildren.find(
(entry) =>
entry.isDirectory() &&
entry.name.startsWith('ffmpeg-') &&
entry.name.endsWith('essentials_build')
)
if (!extractedFfmpegDir) {
throw new Error(
`Unable to find extracted ffmpeg directory in "${ffmpegParentDir}" after unzip`
)
}
await moveDirChildrenUpAndDeleteDir(path.join(ffmpegParentDir, extractedFfmpegDir.name))
} else if (process.platform === 'darwin') {
console.log('Moving: ffmpeg and ffprobe')
await fsPromises.rename(
Expand Down
7 changes: 7 additions & 0 deletions main-src/processQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ async function findDemucsOutputDir(basePath) {
return path.join(basePath, entry.name)
}
}

const hasFilesInBasePath = entries.some((entry) => entry.isFile())
if (hasFilesInBasePath) {
return basePath
}

throw new Error('Unable to find Demucs output directory')
}

Expand Down Expand Up @@ -325,6 +331,7 @@ async function _processVideo(video, tmpDir) {
`Splitting video "${video.videoId}"; ${jobCount} jobs using model "${demucsModelName}"...`
)
const demucsExeArgs = [mediaPath, '-n', demucsModelName, '-j', jobCount]
demucsExeArgs.push('--filename', '{stem}.{ext}')
if (getPyTorchBackend() === 'cpu') {
console.log('Running with "-d cpu" to force CPU instead of CUDA')
demucsExeArgs.push('-d', 'cpu')
Expand Down