使用@mmfpeg React 连接多个视频时出现“内存访问越界”错误

问题描述

我正在尝试使用@ffmpeg 将多个视频与 react 连接起来。我尝试从视频中创建一个 GIF,它工作正常,但我在视频连接方面不走运。我收到“内存访问越界”错误。不知道这里会出现什么问题。 任何帮助将不胜感激。

const mergeVideos = async() => {

let myFile = ''

for (let i = 0; i < video.length; i++) {
  myFile += `file ${ await fetchFile(video[i]) }`

}
ffmpeg.FS('writeFile','MyList.txt',myFile);

await ffmpeg.run('-f','concat','-safe','-i','-codec','-c','output.mp4');

// Read the result
 data = ffmpeg.FS('readFile','output.mp4');

// Create a URL
const url = URL.createObjectURL(new Blob([data.buffer],{ type: 'video/mp4'}));

setMergedVideos(url)

}

enter image description here

解决方法

尝试将此参数 -max_muxing_queue_size 9999 添加到 ffmpeg:

ffmpeg -y -max_muxing_queue_size 9999 -f concat -i "join.txt" -c:v h264_nvenc -pix_fmt yuv420p -b:v 10M -preset slow "Joinned.mp4"
,

花了无数个小时之后,我终于发现了我的错误。我正在将从 fetchFile 返回的 uInt8Array 写入 txt 文件,该文件错误并导致内存绑定错误。正确的做法是将uInt8Array写入内存,将文件名写入txt文件。

aws s3 cp s3://bucket/object.gz - | zcat | wc -l

};