Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
1628a6d
1
Parent(s):
8d9e872
more deug
Browse files
src/core/ffmpeg/concatenateVideosWithAudio.mts
CHANGED
@@ -93,10 +93,14 @@ export const concatenateVideosWithAudio = async ({
|
|
93 |
ffmpegCommand = ffmpegCommand.outputOptions('-loglevel', 'debug');
|
94 |
|
95 |
// If additional audio is provided, add audio to ffmpeg command
|
96 |
-
if (audioFilePath) {
|
|
|
|
|
97 |
ffmpegCommand = ffmpegCommand.addInput(audioFilePath);
|
98 |
// If the input video already has audio, we will mix it with additional audio
|
99 |
if (hasOriginalAudio) {
|
|
|
|
|
100 |
const filterComplex = `
|
101 |
[0:a]volume=${videoTracksVolume}[a0];
|
102 |
[1:a]volume=${audioTrackVolume}[a1];
|
@@ -111,6 +115,8 @@ export const concatenateVideosWithAudio = async ({
|
|
111 |
'-c:a', 'aac',
|
112 |
]);
|
113 |
} else {
|
|
|
|
|
114 |
// If the input video has no audio, just use the additional audio as is
|
115 |
ffmpegCommand = ffmpegCommand.outputOptions([
|
116 |
'-map', '0:v',
|
@@ -120,6 +126,8 @@ export const concatenateVideosWithAudio = async ({
|
|
120 |
]);
|
121 |
}
|
122 |
} else {
|
|
|
|
|
123 |
// If no additional audio is provided, simply copy the video stream
|
124 |
ffmpegCommand = ffmpegCommand.outputOptions([
|
125 |
'-c:v', 'copy',
|
@@ -140,11 +148,11 @@ export const concatenateVideosWithAudio = async ({
|
|
140 |
finalOutputFilePath
|
141 |
})
|
142 |
|
143 |
-
|
144 |
// Set up event handlers for ffmpeg processing
|
145 |
const promise = new Promise<string>((resolve, reject) => {
|
146 |
ffmpegCommand.on('error', (err) => {
|
147 |
-
console.error("concatenateVideosWithAudio:
|
|
|
148 |
reject(err);
|
149 |
}).on('end', async () => {
|
150 |
// When ffmpeg finishes processing, resolve the promise with file info
|
|
|
93 |
ffmpegCommand = ffmpegCommand.outputOptions('-loglevel', 'debug');
|
94 |
|
95 |
// If additional audio is provided, add audio to ffmpeg command
|
96 |
+
if (typeof audioFilePath === "string" && audioFilePath.length > 0) {
|
97 |
+
console.log(`concatenateVideosWithAudio: adding an audio file path: ${audioFilePath}`)
|
98 |
+
|
99 |
ffmpegCommand = ffmpegCommand.addInput(audioFilePath);
|
100 |
// If the input video already has audio, we will mix it with additional audio
|
101 |
if (hasOriginalAudio) {
|
102 |
+
console.log(`concatenateVideosWithAudio: case 1: additional audio was provided, and we already have audio: we mix`)
|
103 |
+
|
104 |
const filterComplex = `
|
105 |
[0:a]volume=${videoTracksVolume}[a0];
|
106 |
[1:a]volume=${audioTrackVolume}[a1];
|
|
|
115 |
'-c:a', 'aac',
|
116 |
]);
|
117 |
} else {
|
118 |
+
console.log(`concatenateVideosWithAudio: case 2: additional audio was provided, but we don't already have audio: we overwrite`)
|
119 |
+
|
120 |
// If the input video has no audio, just use the additional audio as is
|
121 |
ffmpegCommand = ffmpegCommand.outputOptions([
|
122 |
'-map', '0:v',
|
|
|
126 |
]);
|
127 |
}
|
128 |
} else {
|
129 |
+
console.log(`concatenateVideosWithAudio: case 3: no additional audio provided, we leave the audio as-is`)
|
130 |
+
|
131 |
// If no additional audio is provided, simply copy the video stream
|
132 |
ffmpegCommand = ffmpegCommand.outputOptions([
|
133 |
'-c:v', 'copy',
|
|
|
148 |
finalOutputFilePath
|
149 |
})
|
150 |
|
|
|
151 |
// Set up event handlers for ffmpeg processing
|
152 |
const promise = new Promise<string>((resolve, reject) => {
|
153 |
ffmpegCommand.on('error', (err) => {
|
154 |
+
console.error("concatenateVideosWithAudio: error during ffmpeg processing");
|
155 |
+
console.error(err)
|
156 |
reject(err);
|
157 |
}).on('end', async () => {
|
158 |
// When ffmpeg finishes processing, resolve the promise with file info
|
src/main.mts
CHANGED
@@ -146,6 +146,7 @@ export async function clapToTmpVideoFilePath({
|
|
146 |
|
147 |
if (clearTmpFilesAtEnd) {
|
148 |
// we delete all the temporary assets
|
|
|
149 |
await deleteFilesWithName(outputDir, `tmp_asset_`)
|
150 |
}
|
151 |
|
|
|
146 |
|
147 |
if (clearTmpFilesAtEnd) {
|
148 |
// we delete all the temporary assets
|
149 |
+
console.log(`clapToTmpVideoFilePath: calling deleteFilesWithName(${outputDir}, 'tmp_asset_')`)
|
150 |
await deleteFilesWithName(outputDir, `tmp_asset_`)
|
151 |
}
|
152 |
|