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)
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
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.
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)
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
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.