ffmpeg 音频合并与音量调整和侧链处理停止工作

ffmpeg 音频合并与音量调整和侧链处理停止工作

我正在尝试将立体声背景音乐与单声道画外音音频合并,并进行音量调节和侧链处理,以便在播放画外音时降低音乐音量。此命令以前工作正常。没有任何变化。但对于我的新画外音文件,它抛出了以下错误。我已经检查了媒体文件中的画外音 mp3 文件属性,包括旧的(以前有效的)和新的,它们完全相同。有什么建议可以帮忙吗?我尝试添加各种格式过滤器的组合,但不幸的是没有帮助。

我可以让它与 amix 而不是 amerge 一起工作,但是 amix 的输出质量很差,所以这也不是一个选择。

画外音文件属性:

Format                                   : MPEG Audio
Format version                           : Version 2
Format profile                           : Layer 3
Duration                                 : 1 min 25 s
Bit rate mode                            : Constant
Bit rate                                 : 32.0 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 24.0 kHz
Compression mode                         : Lossy
Stream size                              : 334 KiB (100%)

FFMPEG 命令:

    ffmpeg_command = [
        'ffmpeg',
        '-i', background,
        '-i', voiceover,
        '-filter_complex', '[1:a]adelay=5000|5000,volume=1.5,apad[a];[0:a]volume=0.7[b];[a]asplit=2[sc][mix];[b][sc]sidechaincompress=threshold=0.05:ratio=20:level_sc=1:release=500:attack=1[compr];[compr][mix]amerge',
        '-vn',
        'output.mp3'
    ]

现在抛出错误:

ffmpeg version 6.0-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers  
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)  
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint\r\n  
libavutil      58.  2.100 / 58.  2.100\r\n  
libavcodec     60.  3.100 / 60.  3.100\r\n  
libavformat    60.  3.100 / 60.  3.100\r\n  
libavdevice    60.  1.100 / 60.  1.100\r\n  
libavfilter     9.  3.100 /  9.  3.100\r\n  
libswscale      7.  1.100 /  7.  1.100\r\n  
libswresample   4. 10.100 /  4. 10.100\r\n  
libpostproc    57.  1.100 / 57.  1.100\r\n
Input #0, mp3, from 'C:\\Kaushal\\video projects\\free music\\auto vid gen\\Bet On It - Silent Partner.mp3':\r\n  
Metadata:\r\n
    title           : Bet On It\r\n
    artist          : Silent Partner\r\n
    album           : YouTube Audio Library\r\n
    genre           : Jazz & Blues\r\n
    encoder         : Google\r\n
  Duration: 00:03:17.90, start: 0.025057, bitrate: 320 kb/s\r\n
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s\r\n
    Metadata:\r\n
      encoder         : Lavf\r\n
[mp3 @ 000001dc59edfd00] Estimating duration from bitrate, this may be inaccurate\r\n
Input #1, mp3, from 'E:\\Y&H Source\\YHAI\\Classic black tuxedo\\solo (1).mp3':\r\n
  Duration: 00:01:25.39, start: 0.000000, bitrate: 32 kb/s\r\n
  Stream #1:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s\r\n
Stream mapping:\r\n
  Stream #0:0 (mp3float) -> volume:default\r\n
  Stream #1:0 (mp3float) -> adelay:default\r\n
  amerge:default -> Stream #0:0 (libmp3lame)\r\n
Press [q] to stop, [?] for help\r\n
[Parsed_amerge_6 @ 000001dc59f66c00] No channel layout for input 1\r\n
    Last message repeated 1 times\r\n
[AVFilterGraph @ 000001dc59f63780] The following filters could not choose their formats: Parsed_amerge_6\r\n
Consider inserting the (a)format filter near their input or output.\r\n
Error reinitializing filters!\r\n
Failed to inject frame into filter network: I/O error\r\n
Error while processing the decoded data for stream #0:0\r\n
Conversion failed!\r\n"
Traceback (most recent call last):
  File "C:\Kaushal\Stable-Diffusion\vid_API.py", line 270, in <module>
    create_vid(image_dir, 30, channel="YH") # channel should be YBAI or YH
  File "C:\Kaushal\Stable-Diffusion\vid_API.py", line 121, in create_vid
    audio_clip = AudioFileClip(merged_audio_path).set_end(img_count * ( image_display_duration + transition_duration))
  File "C:\Users\KD\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 70, in __init__
    self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes,
  File "C:\Users\KD\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 51, in __init__
    infos = ffmpeg_parse_infos(filename)
  File "C:\Users\KD\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 244, in ffmpeg_parse_infos
    is_GIF = filename.endswith('.gif')
AttributeError: 'int' object has no attribute 'endswith'

相关内容