R
R
RokeAlvo2019-08-31 10:10:34
Python
RokeAlvo, 2019-08-31 10:10:34

How to work with ffmpeg-python library?

A simple example from the documentation:

input = ffmpeg.input('reg.mp4')
audio = input.audio.filter("aecho", 0.8, 0.9, 1000, 0.3)
video = input.video.hflip()
out = ffmpeg.output(audio, video, 'out.mp4').run()

result:
Traceback (most recent call last):
  File "C:/Users/RokeAlvo/Desktop/js/project/audio/extract_audio.py", line 8, in <module>
    out_audio = ffmpeg.output(source_video, 'out.mp4').run()
  File "C:\Users\RokeAlvo\Desktop\js\project\audio\venv\lib\site-packages\ffmpeg\_run.py", line 320, in run
    overwrite_output=overwrite_output,
  File "C:\Users\RokeAlvo\Desktop\js\project\audio\venv\lib\site-packages\ffmpeg\_run.py", line 285, in run_async
    args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
  File "C:\Users\RokeAlvo\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\RokeAlvo\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] Не удается найти указанный файл

ffmpeg is written in the path (although I wanted to use the library so as not to be tied to the ffmpeg installation)
PS I figured out why it doesn’t work - it’s in the virtual environment, this library is just a wrapper over ffmpeg, which must be installed on the system ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RokeAlvo, 2019-08-31
@RokeAlvo

I'll answer myself:
The ffmpeg-python library is a wrapper over ffmpeg and requires the latter to be installed on the system (for winows, the path to ffmpeg.exe must be written in PATH). To run a script that uses ffmpeg-python (and pydub, by the way, the same), from a virtual environment, you need to either add the path to ffmpeg to the PATH of the virtual environment, or put ffmpeg.exe in venv/Scripts

D
Dimonchik, 2019-08-31
@dimonchik2013

in Windows
and everywhere
to put python and either in the user's diru - put a bad tone
either in C: / python37-32
or in virtualenv if you know how to handle

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question