When I run this it is showing ffmpeg has no attribute input. How to solve this?

Question:

def extract_audio_from_video(file_path: str) -> np.ndarray:
    inputfile = ffmpeg.input(file_path)
    out = inputfile.output('-', format='f32le', acodec='pcm_f32le', ac=1, ar='44100')
    raw = out.run(capture_stdout=True)
    del inputfile, out
    return np.frombuffer(raw[0],np.float32)
Asked By: Ashik Ali

||

Answers:

If you’d like to explore a different option, check out [my ffmpegio package:

pip install ffmpegio
import ffmpegio

fs,x = ffmpegio.audio.read(file_path, sample_fmt='f32le', ac=1, ar=44100)
# fs - actual sampling rate
# x - [nx1] numpy array
Answered By: kesh

Got the output……. used same code but intalled ffmpeg for windows and dragged ffmpeg.exe and ffprobe.exe files to the script where i’m running code then it came….
I Went through the installation procedure and came to know that ffmpeg should be installed and then ffmpeg-python should be installed.
After that I gave path of ffmpeg.exe and ffprobe.exe in systemvariables and dragged them to script where i’m running code..
Then it ran without any errors.

Answered By: Ashik Ali
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.