我想将一堆位于桌面上的音乐文件(但是第一步只是尝试将其中的一个文件转换)从.aif转换为.mp3,但是我从ffmpeg收到错误代码1。
我已经安装了ffmpeg和pydub
代码:
from os import path
from pydub import AudioSegment
from pydub.utils import which
AudioSegment.converter = which("ffmpeg")
aif_audio = AudioSegment.from_file("C:/Users/Nick/Desktop/scratch/landonmusic1.aif", format="aif")
aif_audio.export("C:/Users/Nick/Desktop/scratch/landonmusic1.mp3", format="mp3")
我从Python Terminal收到以下反馈:
S C:\Users\Nick\OneDrive\ProgrammingProjects> & C:/Users/Nick/AppData/Local/Programs/Python/Python37-32/python.exe c:/Users/Nick/OneDrive/ProgrammingProjects/Classes/MusicFileConverter.py
Traceback (most recent call last):
File "c:/Users/Nick/OneDrive/ProgrammingProjects/Classes/MusicFileConverter.py", line 10, in <module>
aif_audio = AudioSegment.from_file("C:/Users/Nick/Desktop/scratch/landonmusic1.aif", format="aif")
File "C:\Users\Nick\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\audio_segment.py", line 704, in from_file
p.returncode, p_err))
pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1
ffmpeg / avlib的输出:
b"ffmpeg version N-93431-g6dc1da416e Copyright (c) 2000-2019 the FFmpeg developers\r\n built with gcc 8.2.1 (GCC) 20190212\r\n configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt\r\n libavutil 56. 26.100 / 56. 26.100\r\n libavcodec 58. 47.105 / 58. 47.105\r\n libavformat 58. 26.101 / 58. 26.101\r\n libavdevice 58. 7.100 / 58. 7.100\r\n libavfilter 7. 48.100 / 7. 48.100\r\n libswscale 5. 4.100 / 5. 4.100\r\n libswresample 3. 4.100 / 3. 4.100\r\n libpostproc 55. 4.100 / 55. 4.100\r\nUnknown input format: 'aif'\r\n"