gpt4 book ai didi

javascript - Ffmpeg 在 AWS Lambda 函数中返回错误代码 1

转载 作者:行者123 更新时间:2023-12-04 22:59:35 32 4
gpt4 key购买 nike

我正在运行一个 lambda 函数,它需要一个 mp4视频,并添加 png 的水印右下角顶部的图像(带有 10px 边距)。然后它将该图像输出到一个临时位置。它不断失败,Error code 1 ,但这不是很有帮助。我正在使用 ffmpeg 的二进制版本在代码的主目录中指定。我知道ffmpeg由于以这种方式在另一个 lambda 函数中使用它,因此设置正确,该方法有效。但是添加覆盖失败。这是我的代码的相关部分:

function addWatermark(next) {
var ffmpeg = child_process.spawn("ffmpeg", [
"-i", target, // url to stream from
"-i", watermarkPath,
"-filter_complex" ,"overlay=x=W-w-10:y=H-h-10:format=rgb,format=yuv420p",
"-c:a", "copy",
"pipe:1"
]);
ffmpeg.on("error", function(err) {
console.log(err);
})
ffmpeg.on("close", function(code) {
if (code != 0 ) {
console.log("child process exited with code " + code); // Always exits here.
} else {
console.log("Processing finished !");
}
tmpFile.end();
next(code);
});
tmpFile.on("error", function(err) {
console.log("stream err: ", err);
});
ffmpeg.on("end", function() {
tmpFile.end();
})
ffmpeg.stdout.pipe(tmpFile)
.on("error", function(err){
console.log("error while writing: ",err);
});
}

谁能发现可能出了什么问题?

更新

我设法打印出更多日志,但出现错误:
[NULL @ 0x42923e0] Unable to find a suitable output format for 'pipe:1'

最佳答案

您必须使用 -f format 告诉 ffmpeg 您想要输出的格式。选项。运行ffmpeg -formats获取支持的格式列表。

来自 ffmpeg documentation :

-f fmt (input/output) Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases.



例如,如果您希望输出为 MPEG-4,那么您对 ​​ffmpeg 的调用应如下所示:
   var ffmpeg = child_process.spawn("ffmpeg", [
"-i", target, // url to stream from
"-i", watermarkPath,
"-filter_complex" ,"overlay=x=W-w-10:y=H-h-10:format=rgb,format=yuv420p",
"-c:a", "copy",
"-f", "m4v",
"pipe:1"
]);

关于javascript - Ffmpeg 在 AWS Lambda 函数中返回错误代码 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49797534/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com