ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

AttributeError: module 'ffmpeg' has no attribute 'input'

Open iamtahirkhan6 opened this issue 5 years ago • 43 comments

Traceback (most recent call last): File "/main/ffmpeg.py", line 1, in import ffmpeg File "/main/ffmpeg.py", line 2, in stream = ffmpeg.input('video.mp4') AttributeError: module 'ffmpeg' has no attribute 'input'

iamtahirkhan6 avatar Mar 09 '19 06:03 iamtahirkhan6

pip install ffmpeg-python instead of pip install ffmpeg

kkroening avatar Mar 09 '19 08:03 kkroening

I had the same error, because python-ffmpeg was installed instead of ffmpeg-python. Therefore this can be considered as fixed.

muellermartin avatar May 28 '19 15:05 muellermartin

try another filename (don't use same name as your imported package)

hldh214 avatar Jul 23 '19 07:07 hldh214

It doesn't solve my problem. I have install pip install ffmpeg-python

import ffmpeg filep = '/path/to/my/file.mp4' stream = ffmpeg.input(filep) Traceback (most recent call last): File "", line 1, in AttributeError: module 'ffmpeg' has no attribute 'input'

tung-nguyen-uet avatar Sep 12 '19 09:09 tung-nguyen-uet

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

vinooo1095 avatar Dec 04 '19 09:12 vinooo1095

I have same problem, install and uninstall the module multiple times.

but i forgot to install ffmpeg package.

shgninc avatar Jun 21 '20 14:06 shgninc

you will probably end up with that exact error if you do : pip install python-ffmpeg

instead of : pip install ffmpeg-python

at least, I did ...

nlsdvl avatar Oct 06 '20 06:10 nlsdvl

  1. Make sure you had pip install ffmpeg-python
  2. You should copy the ffmpeg.exe to you ***.py file work directory 3c211f825bfb22c465eb9ea41706ec0

CharlesChen-ccc avatar Nov 17 '20 08:11 CharlesChen-ccc

If I install ffmpeg + ffmpeg-python I see the same issue.

If I install only ffmpeg-python I see "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

rupshac avatar Mar 09 '21 06:03 rupshac

Traceback (most recent call last): File "/main/ffmpeg.py", line 1, in import ffmpeg File "/main/ffmpeg.py", line 2, in stream = ffmpeg.input('video.mp4') AttributeError: module 'ffmpeg' has no attribute 'input'

If you're silly like me and create a file named ffmpeg.py to test things out, the first command you call is obviously ffmpeg.input(...). Since you're re-defining ffmpeg it does not contain ffmpeg.input.

Therefore, AttributeError: module 'ffmpeg' has no attribute 'input'

The solution to this: Make sure your Python file isn't named ffmpeg.py

hobbitsyfeet avatar Mar 11 '21 00:03 hobbitsyfeet

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

thank you! If it wasn't for you, I would have been tortured to death.

784682065 avatar Apr 21 '21 11:04 784682065

step 1:sudo apt install ffmpeg step 2:pip install ffmpeg-python step 3:pip uninstall ffmpeg

ShawKai666 avatar Dec 14 '21 10:12 ShawKai666

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

Thank you very much!

KalininY avatar Feb 10 '22 15:02 KalininY

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python. uninstall both with: pip uninstall ffmpeg pip uninstall ffmpeg-python

and install ffmpeg-python again with : pip install ffmpeg-python

This solved the problem in my system :)

Thanks, you help me a lot!

lixueqidaytoy avatar Mar 14 '22 15:03 lixueqidaytoy

I've tried all of the above solutions, I either get "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

mikhail-okrochkov avatar Mar 25 '22 03:03 mikhail-okrochkov

I've tried all of the above solutions, I either get "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

I still have this problem in the Jupyter notebook, so I use vs code. AttributeError: module 'ffmpeg' has no attribute 'input' this can be solved, but I get new error.

AttributeError: module 'ffmpeg' has no attribute 'run'

if you get this, you just need to turn colored frames into video.

lixueqidaytoy avatar Mar 25 '22 06:03 lixueqidaytoy

I'm working in vscode and I still run into this issue.

mikhail-okrochkov avatar Mar 25 '22 13:03 mikhail-okrochkov

I've tried all of the above solutions, I either get "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

or

AttributeError: module 'ffmpeg' has no attribute 'input'

I've tried uninstall and re-installing in various different orders

I had the same problem until I tried sudo apt install ffmpeg

gyq517 avatar Jun 09 '22 09:06 gyq517

The answer is here. You probably didn't install ffmpeg completely and setup the environmental variables. Link shows all the steps.

https://stackoverflow.com/questions/54262306/ffmpeg-python-wrapper-ffmpeg-run-getting-filenotfounderror

johntsunami avatar Jun 21 '22 19:06 johntsunami

May your interpreter has no ffmpeg-python

orange5E06 avatar Jul 13 '22 15:07 orange5E06

Here is a possible fix to the error: AttributeError: module 'ffmpeg' has no attribute 'input'

I found that the above error occurs only when my python script is named 'ffmpeg.py'

Renaming the script solves the above error in my case

michalbartkowski avatar Sep 16 '22 12:09 michalbartkowski

So, I tried both uninstalls as follows,

Not much change from befefore... (ytwhisper) Wesleys-MacBook-Air:whisper wesley$ pip uninstall ffmpeg WARNING: Skipping ffmpeg as it is not installed. (ytwhisper) Wesleys-MacBook-Air:whisper wesley$ pip uninstall ffmpeg-python Found existing installation: ffmpeg-python 0.2.0 Uninstalling ffmpeg-python-0.2.0: Would remove: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ffmpeg/* /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ffmpeg_python-0.2.0.dist-info/* Proceed (Y/n)? y Successfully uninstalled ffmpeg-python-0.2.0 (ytwhisper) Wesleys-MacBook-Air:whisper wesley$ pip install ffmpeg-python Collecting ffmpeg-python Using cached ffmpeg_python-0.2.0-py3-none-any.whl (25 kB) Requirement already satisfied: future in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from ffmpeg-python) (0.18.2) Installing collected packages: ffmpeg-python Successfully installed ffmpeg-python-0.2.0 (ytwhisper) Wesleys-MacBook-Air:whisper wesley$ yt_whisper "https://www.youtube.com/watch?v=dQw4w9WgXcQ"yt_whisper "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --model medium Downloaded video "Rick Astley - Never Gonna Give You Up (Official Music Video)". Generating subtitles... Downloaded video "Rick Astley - Never Gonna Give You Up (Official Music Video)". Generating subtitles... Traceback (most recent call last): File "/opt/homebrew/lib/python3.10/site-packages/whisper/audio.py", line 42, in load_audio ffmpeg.input(file, threads=0) AttributeError: module 'ffmpeg' has no attribute 'input'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/homebrew/bin/yt_whisper", line 8, in sys.exit(main()) File "/opt/homebrew/lib/python3.10/site-packages/yt_whisper/cli.py", line 49, in main result = model.transcribe(audio_path, **args) File "/opt/homebrew/lib/python3.10/site-packages/whisper/transcribe.py", line 84, in transcribe mel = log_mel_spectrogram(audio) File "/opt/homebrew/lib/python3.10/site-packages/whisper/audio.py", line 111, in log_mel_spectrogram audio = load_audio(audio) File "/opt/homebrew/lib/python3.10/site-packages/whisper/audio.py", line 46, in load_audio except ffmpeg.Error as e: AttributeError: module 'ffmpeg' has no attribute 'Error' (ytwhisper) Wesleys-MacBook-Air:whisper wesley$

swankwc avatar Jan 09 '23 21:01 swankwc

I used conda install -c conda-forge ffmpeg, and it works. It turned out that ffmpeg installed by pip was of a too old version.

ZZZsleepyheadZZZ avatar Feb 10 '23 03:02 ZZZsleepyheadZZZ

pip install python-ffmpeg

this is right

459737087 avatar Feb 16 '23 08:02 459737087

Finally worked for me after doing this,

  1. pip uninstall ffmpeg-python
  2. pip3 install ffmpeg-python

So try installing with pip3..

dinuthomas avatar Mar 14 '23 15:03 dinuthomas

This worked for me:

  1. uninstall ffmpeg-python
  2. pip install ffmpeg
  3. pip install ffmpeg-python

Suvi-dha avatar Apr 11 '23 07:04 Suvi-dha

I have a very simple code - [ import whisper

model = whisper.load_model("base") result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) print(result["text"]) ]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error [ Traceback (most recent call last): File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio ffmpeg.input(file, threads=0) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "C:\py39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\py39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ] Can you please suggest a way-forward for addressing this?

githmashwinkumar avatar Apr 22 '23 15:04 githmashwinkumar

Thanks. you are my hero!It works

pardon-hnu avatar Apr 24 '23 12:04 pardon-hnu

I have a very simple code - [ import whisper

model = whisper.load_model("base") result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) print(result["text"]) ]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error [ Traceback (most recent call last): File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio ffmpeg.input(file, threads=0) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "C:\py39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\py39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ] Can you please suggest a way-forward for addressing this?

Installing System.Speech from nuget manager resolved this issue. Refered to this link

githmashwinkumar avatar Apr 24 '23 13:04 githmashwinkumar

I have a very simple code - [ import whisper

model = whisper.load_model("base") result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) print(result["text"]) ]

Have tried with "pip install python-ffmpeg" when it gave the error - "AttributeError: module 'ffmpeg' has no attribute 'Error'". Then tried with "pip install ffmpeg" and "pip install ffmpeg-python". Now it is throwing this error [ Traceback (most recent call last): File "D:\Newfolder\ds\ML\patrec\rec.py", line 4, in result = model.transcribe("D:\Newfolder\audio.mp3",fp16=False) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 130, in log_mel_spectrogram audio = load_audio(audio) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\whisper\audio.py", line 46, in load_audio ffmpeg.input(file, threads=0) File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 313, in run process = run_async( File "D:\Newfolder\ds\ML\patrec\venv\lib\site-packages\ffmpeg_run.py", line 284, in run_async return subprocess.Popen( File "C:\py39\lib\subprocess.py", line 951, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\py39\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ] Can you please suggest a way-forward for addressing this?

As @vinooo1095 suggested already:

I'm guessing this happens if you've installed both, ffmpeg and ffmpeg-python.

Uninstall both with:

pip3 uninstall ffmpeg
pip3 uninstall ffmpeg-python

Then ONLY install ffmpeg-python again with:

pip3 install ffmpeg-python

raduking avatar May 11 '23 15:05 raduking