Dan*_*ver 1 ffmpeg fluent-ffmpeg
我正在尝试将以下复杂过滤器转换为 Fluent FFMPEG 命令,但我无法弄清楚映射是如何工作的。
ffmpeg -i audio.mp3 -filter_complex "[0:a]showfreqs=s=200x100:colors=white|white,format=yuv420p[vid]" -map "[vid]" -map 0:a video.mp4
到目前为止,这是我所拥有的,但我收到有关“vid”流的错误。
ffmpeg()
.input("audio.mp3")
.audioCodec("aac")
.audioBitrate("320")
.complexFilter(
{
filter: "showfreqs",
options: { s: "200x100" },
inputs: "0:a",
},
{
filter: "format",
options: { pix_fmts: "yuv420p" },
outputs: ["vid"],
}
)
.outputOptions(['-map "[vid]"', "-map 0:a"])
.save(spectrumTmp)
Run Code Online (Sandbox Code Playgroud)
错误: ffmpeg exited with code 1: Stream map '"[vid]"' matches no streams.
To ignore this, add a trailing '?' to the map.
如果我添加一个尾随 '?' 在outputOptions我得到一个没有视频流的文件。
解决了这个问题。我的原始代码有三处错误:
complexFilter需求是对象的数组,我错过了阵列支架。outputOptions最终的工作代码:
ffmpeg()
.input("audio.mp3")
.audioCodec("aac")
.audioBitrate("320")
.complexFilter([
{
filter: "showfreqs",
options: { s: "200x100" },
inputs: "0:a",
outputs: "[freqs]",
},
{
filter: "format",
options: { pix_fmts: "yuv420p" },
inputs: "[freqs]",
outputs: "[vid]",
},
])
.outputOptions(["-map [vid]", "-map 0:a"])
.save(spectrumTmp)
Run Code Online (Sandbox Code Playgroud)