I am facing difficulty with serverless function to creating video and upload it to digital occan spaces. The ffmpeg gives me error while generating the video. here is my generating and uploading process:
const { PassThrough } = require("stream");
const passThroughStream = **new** PassThrough();
const buffers = [];
passThroughStream.on('data', (chunk) => buffers.push(chunk));
passThroughStream.on('end', async () => {
const buffer = Buffer.concat(buffers);
const contentLength = buffer.length;
try {
const url = await uploadFile(userId, buffer, videoPath, contentLength);
resolve({ url, duration });
} catch (uploadError) {
reject(uploadError);
}
});
ffmpeg()
.input(svgPaths[index][dim])
.loop(
index === audioMappings.length - 1 ? duration + 2.7 : duration
)
.input(audioFilePath)
.audioCodec("aac")
.videoCodec("libx264")
.videoBitrate(950)
.format("mp4")
.fps(25)
.size(dim)
.output(passThroughStream)
.on('start', (commandLine) => {
console.log('Spawned Ffmpeg with command:', commandLine);
})
.on('stderr', (stderrLine) => {
console.log('Stderr output:', stderrLine);
})
.on('error', (err, stdout, stderr) => {
const errorResponse = { error: "ffmpeg error", details: err.message, stdout, stderr };
reject(errorResponse);
})
.on('end', () => {
console.log(`ffmpeg processing complete for index ${index} and dimension ${dim}`);
})
.run();
});
});
outputVideoPaths.push(result.url);
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey!
Can you share the exact error that you are getting here?
Keep in mind that functions have the following limits:
The maximum timeout is 15 minutes. This includes initialization and function execution.
The maximum size of input parameters is 1 MB.
The maximum size of result responses is 1 MB.
The maximum size of the built function is 48 MB. See the Building Functions reference for details on the build process.
The maximum build time for remote builds is 2 minutes.
Memory is limited from 128 MB – 1 GB, defaulting to 256 MB.
The Limits section allows for editing the function’s timeout and memory limits. Click the Edit text to change these settings:
The maximum memory setting is currently 1024MB (1GB) so if your function needs more than that, it might explain the problem.
If this is the case here, you might be better off using a Droplet instead where you would have more control over the environment.
- Bobby