ffmpeg复杂过滤:如何解决

时间:2019-10-29 02:09:40

标签: audio video ffmpeg lv2

好的,我有一个带有--enable-lv2的编译的ffmpeg。这允许第三方插件工作。我使用的插件是:https://github.com/lucianodato/speech-denoiser,它是一个围绕此RNN降噪库的插件:https://github.com/GregorR/rnnoise-models

以下命令有效:

(1)ffmpeg -i input.mov -filter_complex '[0:a]lv2=plugin=https\\://github.com/lucianodato/speech-denoiser[audio]' -map "[audio]" output.wav

(2)ffmpeg -i input.mov -filter_complex '[0:v]copy[video]' -map "[video]" output.mov

但是当我进行组合时,那是行不通的。

ffmpeg -i input.mov -filter_complex '[0:a]lv2=plugin=https\\://github.com/lucianodato/speech-denoiser[audio];[0:v]copy[video]' -map "[audio]" -map "[video]" output.mov

我认为错误本质上是这样的:

Channel layout change is not supported
Error while filtering: Not yet implemented in FFmpeg, patches welcome
Failed to inject frame into filter network: Not yet implemented in FFmpeg, patches welcome
Error while processing the decoded data for stream #0:0

我的猜测:该第三方过滤器未配置为与音频以外的任何其他输出流一起使用。

我的问题:我可以以某种方式欺骗这个正在输出到音频文件的第三方插件,同时仍然将所有内容输出到视频文件吗?

注意:我知道,我可以简单地将其分成2个命令并完成,所以我想知道是否可以通过一个ffmpeg命令来完成此操作。我如何将其拆分为2个命令,如下所示:

ffmpeg -i out_cropped.mov -af 'lv2=plugin=https\\://github.com/lucianodato/speech-denoiser' -vcodec copy out_cropped_denoised.wav 

&&

ffmpeg -i out_cropped.mov -i out_cropped_denoised.wav -c:v copy -map 0:v:0 -map 1:a:0 out_cropped_denoised.mov

但是我希望能够将它们全部放在一个复杂的过滤器中(理想情况下),或者至少放在一个ffmpeg命令中。

附录:这是完整的互动方式

ffmpeg -i input.mov -filter_complex '[0:a]lv2=plugin=https\\://github.com/lucianodato/speech-denoiser[audio];[0:v]copy[video]' -map "[audio]" -map "[video]" output.mov
ffmpeg version N-95577-g68f623d644 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.8)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --enable-lv2 --samples=fate-suite/
  libavutil      56. 35.101 / 56. 35.101
  libavcodec     58. 60.100 / 58. 60.100
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 65.100 /  7. 65.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf58.29.100
  Duration: 00:16:19.11, start: 0.000000, bitrate: 1341 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x960, 1262 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc58.54.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
File 'output.mov' already exists. Overwrite? [y/N] y

#ote:我输入是,然后出现了。

Stream mapping:
  Stream #0:0 (h264) -> copy
  Stream #0:1 (aac) -> lv2
  lv2 -> Stream #0:0 (aac)
  copy -> Stream #0:1 (libx264)
Press [q] to stop, [?] for help
[out_0_0 @ 0x7fa6811066c0] Channel layout change is not supported
Error while filtering: Not yet implemented in FFmpeg, patches welcome
Failed to inject frame into filter network: Not yet implemented in FFmpeg, patches welcome
Error while processing the decoded data for stream #0:0

1 个答案:

答案 0 :(得分:1)

我忘了在这里发布答案,但是我重新编译了ffmpeg项目。

然后我可以使用此命令ffmpeg -i out_cropped.mov -af 'lv2=plugin=https\\://github.com/lucianodato/speech-denoiser' -vcodec copy out_cropped_denoised.wav

我记得我曾为自己写过一份编译指南,因为编译似乎很可怕。而且(只是一点点),但是最终它是完全可行的。

这是指南。

如何在Mac上编译ffmpeg,lv2和语音降噪器并在Mac上对音频文件进行降噪(并将其放入视频中!)

在MacOS上编译ffmpeg的有用指南:

安装独立机
brew install automake fdk-aac git lame libass libtool libvorbis libvpx \
opus sdl shtool texi2html theora wget x264 x265 xvid nasm
安装lilv(对lv2的依赖性)
brew install lilv #because of ERROR: lilv-0 not found using pkg-config when doing ./configure right away
配置ffmpeg
./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass \
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --enable-lv2 \
--samples=fate-suite/
制作并安装
make
sudo make install
安装语音降噪器依赖项+项目本身
brew update
brew cask uninstall oclint
brew install lv2 meson ninja pkg-config autoconf m4 libtool automake

#Download and install speech denoiser
git clone https://github.com/lucianodato/speech-denoiser.git
cd speech-denoiser
chmod +x install.sh && ./install.sh
检查安装是否存在
lv2ls #You got this command from installing lilv

输出:https://github.com/lucianodato/speech-denoiser (是网址)

使用您的命令!
#audio to denoised audio
ffmpeg -i out_cropped.mov -af 'lv2=plugin=https\\://github.com/lucianodato/speech-denoiser' -vcodec copy out_cropped_denoised.wav 

#for if you want to put it with a video
&&

ffmpeg -i out_cropped.mov -i out_cropped_denoised.wav -c:v copy -map 0:v:0 -map 1:a:0 out_cropped_denoised.mov