Language/python

[Python] RuntimeWarning: Couldn’t find ffprobe or avprobe – defaulting to ffprobe, but may not workwarn 에러 해결

MOMOBOB 2024. 5. 13. 06:13
반응형

 

Error

Window에서 Python을 이용해서 AudioSegment.from_mp3으로 음성파일 로드시 아래와 같은 에러가 발생함.

C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "d:/main.py", line 114, in <module>
    soundManager.sum_sounds(resultPath, clipPath, clipExp, resultFileName, count)
  File "d:\sound.py", line 63, in sum_sounds
    result += pause2 + AudioSegment.from_mp3(clipPath + self.introFile + clipExp)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
    return cls.from_file(file, 'mp3', parameters=parameters)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

 

 

반응형

 


Solution

pydub의 AudioSegment를 사용하기 위해서는 ffmpeg, ffprobe 등 프로그램이 필요함.

 

MaxOS 등 리눅스 기반의 OS에는 ffmpeg 및 ffprobe가 기본적으로 설치되어 있는 경우가 많아 별도 설치없이 실행이 되지만, Winodows의 경우 프로그램을 설치 후 설정을 해줘야함.

 

1. ffmpeg 설치

 

아래 링크에서 설치 파일 다운로드

zip파일 압축 해제

 

압축 해제한 폴더의 bin 폴더 하위 .exe 파일들을 원하는 경로로 이동 (ex. C:\ffmpeg\bin)

 

 

2. 환경변수 설정

아래와 같이 환경변수 설정하면 정상적으로 실행됨.

 

 

3. 환경변수 없이 코드상에서 설정하는 법

 

아래와 같이 코드상에서 설정하고 실행해도 정상적으로 동작함.

from pydub import AudioSegment

AudioSegment.converter = "C:/ffmpeg/bin/ffmpeg.exe"
AudioSegment.ffmpeg = "C:/ffmpeg/bin/ffmpeg.exe"
AudioSegment.ffprobe = "C:/ffmpeg/bin/ffprobe.exe"

 

 

 


Thank you!

 

 

반응형