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

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

Open swpucl opened this issue 6 years ago • 26 comments

swpucl avatar Aug 12 '19 06:08 swpucl

I've found the problem, the ffmpeg library could not be found, if you're on macOS, just install it through homebrew: brew install ffmpeg

devsdmf avatar Aug 13 '19 18:08 devsdmf

ffmpeg-python 0.1.17 python 3.6.9 ubuntu 18.4

inpath = '/home/project/demo/video/demo1.mp4' def read_frame_as_jpeg(inpath, frame_num):

out, err = (
    ffmpeg
    .input(in_filename)
    .filter('select', 'gte(n,{})'.format(frame_num))
    .output('pipe:', vframes=1, format='image2', vcodec='mjpeg')
    .run(capture_stdout=True)
)
return out

out = read_frame_as_jpeg(inpath, 2)

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

blakeliu avatar Sep 07 '19 02:09 blakeliu

python read_frame_as_jpeg.py in.mp4 1

Traceback (most recent call last): File "read_frame_as_jpeg.py", line 27, in out = read_frame_as_jpeg(args.in_filename, args.frame_num) File "read_frame_as_jpeg.py", line 20, in read_frame_as_jpeg .run(capture_stdout=True) File "/home/blake/anaconda3/lib/python3.6/site-packages/ffmpeg/_run.py", line 300, in run overwrite_output=overwrite_output, File "/home/blake/anaconda3/lib/python3.6/site-packages/ffmpeg/_run.py", line 272, in run_async args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream) File "/home/blake/anaconda3/lib/python3.6/subprocess.py", line 729, in init restore_signals, start_new_session) File "/home/blake/anaconda3/lib/python3.6/subprocess.py", line 1364, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

blakeliu avatar Sep 07 '19 02:09 blakeliu

This works on MacOS, and I presume would also work on Ubuntu though I didn't test it. If you need to control the FFMpeg version or don't want to explain to your user how to install it on their computer you can also add the "cmd" parameter to the .run() command. (ffmpeg .input(inputFile) .output(outputFile, params) .run(cmd='/path_to/ffmpeg') )

DKWoods avatar Sep 10 '19 22:09 DKWoods

python read_frame_as_jpeg.py in.mp4 1 Traceback (most recent call last): File "read_frame_as_jpeg.py", line 27, in out = read_frame_as_jpeg(args.in_filename, args.frame_num) File "read_frame_as_jpeg.py", line 20, in read_frame_as_jpeg .run(capture_stdout=True) File "/home/blake/anaconda3/lib/python3.6/site-packages/ffmpeg/_run.py", line 300, in run overwrite_output=overwrite_output, File "/home/blake/anaconda3/lib/python3.6/site-packages/ffmpeg/_run.py", line 272, in run_async args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream) File "/home/blake/anaconda3/lib/python3.6/subprocess.py", line 729, in init restore_signals, start_new_session) File "/home/blake/anaconda3/lib/python3.6/subprocess.py", line 1364, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

Do you solve it?

swpucl avatar Nov 06 '19 07:11 swpucl

on linux install ffmpeg sudo apt install ffmpeg this worked for me

DALIHILLARY avatar Dec 19 '19 07:12 DALIHILLARY

This works on MacOS, and I presume would also work on Ubuntu though I didn't test it. If you need to control the FFMpeg version or don't want to explain to your user how to install it on their computer you can also add the "cmd" parameter to the .run() command. (ffmpeg .input(inputFile) .output(outputFile, params) .run(cmd='/path_to/ffmpeg') )

Yes, it's working on Ubuntu. In particular: video_stream,err = ( ffmpeg.input('TheBigBangTheory.mkv') .output('pipe:', format='rawvideo') .run(cmd='/path_to/ffmpeg',capture_stdout=True) )

Open-Debin avatar May 05 '20 08:05 Open-Debin

You have to first install the ffmpeg program ..

Ffmpeg-python is just an API to the program.

apt-get install ffmpeg That is if you are using linux

On Tue, May 5, 2020, 11:00 AM Debin Meng [email protected] wrote:

This works on MacOS, and I presume would also work on Ubuntu though I didn't test it. If you need to control the FFMpeg version or don't want to explain to your user how to install it on their computer you can also add the "cmd" parameter to the .run() command. (ffmpeg .input(inputFile) .output(outputFile, params) .run(cmd='/path_to/ffmpeg') )

Yes, it's working on Ubuntu. In particular: video_stream,err = ( ffmpeg.input('TheBigBangTheory.mkv') .output('pipe:', format='rawvideo') .run(cmd='/path_to/ffmpeg',capture_stdout=True) )

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kkroening/ffmpeg-python/issues/251#issuecomment-623913956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXX3EHKM2YFFFNABFAZFWTRP7BTFANCNFSM4IK6LYTQ .

DALIHILLARY avatar May 05 '20 10:05 DALIHILLARY

On Windows, you must set environment variable PATH.

  • set it temporarily in python code.
import os
os.environ['path'] = 'C:\\data\\ffmpeg.exe'
# do someting
  • set it permanently in cmd
setx "PATH" "%PATH%;C:\\data\\ffmpeg.exe" /m

AlbertChanX avatar May 13 '20 03:05 AlbertChanX

A solution from CI test script

curl -O https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz &&
mkdir -p ffmpeg-release &&
tar Jxf ffmpeg-release-amd64-static.tar.xz --strip-components=1 -C ffmpeg-release &&
PATH=$(readlink -f ffmpeg-release):$PATH

Worked for me!

ESWZY avatar Oct 20 '20 06:10 ESWZY

What version(s) of ffmpeg does this package work with? Would you accept a pull request that documents the ffmpeg dependency?

tschaub avatar Jan 12 '21 17:01 tschaub

If I install ffmpeg + ffmpeg-python I see AttributeError: module 'ffmpeg' has no attribute 'input'

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

If I install ffmpeg + ffmpeg-python I see AttributeError: module 'ffmpeg' has no attribute 'input'

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


I was in the exact same situation on windows.
  • Try to reinstall it

    pip uninstall ffmpeg-python
    pip uninstall ffmpeg
    
    pip install ffmpeg-python
    
  • Make sure you have set the environment variable. (You can check in the terminal.)

    C:\Users\ru> ffmpeg
    ffmpeg version N-102166-g1ab74bc193 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 10-win32 (GCC) 20210408
      configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
      libavutil      57.  0.100 / 57.  0.100
      libavcodec     59.  0.100 / 59.  0.100
      libavformat    59.  0.100 / 59.  0.100
      libavdevice    59.  0.100 / 59.  0.100
      libavfilter     8.  0.100 /  8.  0.100
      libswscale      6.  0.100 /  6.  0.100
      libswresample   4.  0.100 /  4.  0.100
      libpostproc    56.  0.100 / 56.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    
  • Reboot your editor.


This is how I solved it😺

3ru avatar Apr 29 '21 12:04 3ru

Is it possible to store FFmpeg output to EFS storage using python?

parthshah27 avatar Oct 18 '21 05:10 parthshah27

If I install ffmpeg + ffmpeg-python I see AttributeError: module 'ffmpeg' has no attribute 'input' If I install only ffmpeg-python I see "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

I was in the exact same situation on windows.

  • Try to reinstall it
    pip uninstall ffmpeg-python
    pip uninstall ffmpeg
    
    pip install ffmpeg-python
    
  • Make sure you have set the environment variable. (You can check in the terminal.)
    C:\Users\ru> ffmpeg
    ffmpeg version N-102166-g1ab74bc193 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 10-win32 (GCC) 20210408
      configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
      libavutil      57.  0.100 / 57.  0.100
      libavcodec     59.  0.100 / 59.  0.100
      libavformat    59.  0.100 / 59.  0.100
      libavdevice    59.  0.100 / 59.  0.100
      libavfilter     8.  0.100 /  8.  0.100
      libswscale      6.  0.100 /  6.  0.100
      libswresample   4.  0.100 /  4.  0.100
      libpostproc    56.  0.100 / 56.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    
  • Reboot your editor.

This is how I solved it😺

this solved it for me too

maphouse avatar Oct 27 '21 01:10 maphouse

For windows 10: Download the ffmpeg.exe here https://ffmpeg.org/download.html extract the folder then change your directory to the bin file (which includes the .exe file) change your input video file path on line 85 (otherwise it will say file not found error) and run.

MrCri5py avatar Dec 08 '21 15:12 MrCri5py

A solution from CI test script

curl -O https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz &&
mkdir -p ffmpeg-release &&
tar Jxf ffmpeg-release-amd64-static.tar.xz --strip-components=1 -C ffmpeg-release &&
PATH=$(readlink -f ffmpeg-release):$PATH

Worked for me!

On Linux, Worked for me too!

Jacoo-Zhao avatar Mar 30 '22 22:03 Jacoo-Zhao

Hi, I am having this error too: FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg' I installed with HomeBrew, but the problem persists. I am guessing that I need to add the path to the bash file, but I do not know if that is the problem and how to do it. If someone can explain me how ti fix this, as detailed as possible (new into Mac), I would really appreciate it.

FernandoJGomez avatar Jun 04 '22 15:06 FernandoJGomez

I also tried this: https://www.youtube.com/watch?v=H1o6MWnmwpY&ab_channel=RickMakes and did not work

FernandoJGomez avatar Jun 04 '22 15:06 FernandoJGomez

well I solved it (I think) following this (https://stackoverflow.com/questions/40509002/ffmpeg-is-not-being-detected-by-spyder): "You need to install a copy of ffmpeg that can be recognized by Anaconda. Please run this command in a terminal to do that": conda install -c conda-forge ffmpeg

FernandoJGomez avatar Jun 04 '22 16:06 FernandoJGomez

Hi 😁👋 This is how l solved my problem in Windows 🪟

We Open the Terminal in admin mode And execute the following command and click yes[y]

choco install ffmpeg

mohamad22mk avatar Sep 29 '22 04:09 mohamad22mk

I've found the problem, the ffmpeg library could not be found, if you're on macOS, just install it through homebrew: brew install ffmpeg

I have a error: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg' When running the python program, specify the path of ffmpeg, Environment variables: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin This is how I solved it

xiuxiuing avatar Dec 29 '22 03:12 xiuxiuing

ffmpeg-python 0.1.17 python 3.6.9 ubuntu 18.4

inpath = '/home/project/demo/video/demo1.mp4' def read_frame_as_jpeg(inpath, frame_num):

out, err = (
    ffmpeg
    .input(in_filename)
    .filter('select', 'gte(n,{})'.format(frame_num))
    .output('pipe:', vframes=1, format='image2', vcodec='mjpeg')
    .run(capture_stdout=True)
)
return out

out = read_frame_as_jpeg(inpath, 2)

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

If you are trying to use ffmpeg with Python, there is no easy or difficult solution. I have tried many ways mentioned here and beyond and simply ffmpeg does not work with Python3 and produces [Errno 2]. An alternative (and the best so far) for me has been executing command line FFmpeg command in python using subprocess.

TeslaGeek avatar Apr 26 '23 18:04 TeslaGeek

well I solved it (I think) following this (https://stackoverflow.com/questions/40509002/ffmpeg-is-not-being-detected-by-spyder): "You need to install a copy of ffmpeg that can be recognized by Anaconda. Please run this command in a terminal to do that": conda install -c conda-forge ffmpeg

Spent a while trying to fix this, and this finally worked. Thank you!

JoshuaEbbert avatar May 25 '23 14:05 JoshuaEbbert

I feel it is a problem with the IDE. I tried executing it in the terminal and it was successfully processed.

chichi55 avatar Oct 08 '23 06:10 chichi55

If I install ffmpeg + ffmpeg-python I see AttributeError: module 'ffmpeg' has no attribute 'input' If I install only ffmpeg-python I see "FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

I was in the exact same situation on windows.

  • Try to reinstall it
    pip uninstall ffmpeg-python
    pip uninstall ffmpeg
    
    pip install ffmpeg-python
    
  • Make sure you have set the environment variable. (You can check in the terminal.)
    C:\Users\ru> ffmpeg
    ffmpeg version N-102166-g1ab74bc193 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 10-win32 (GCC) 20210408
      configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
      libavutil      57.  0.100 / 57.  0.100
      libavcodec     59.  0.100 / 59.  0.100
      libavformat    59.  0.100 / 59.  0.100
      libavdevice    59.  0.100 / 59.  0.100
      libavfilter     8.  0.100 /  8.  0.100
      libswscale      6.  0.100 /  6.  0.100
      libswresample   4.  0.100 /  4.  0.100
      libpostproc    56.  0.100 / 56.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    
  • Reboot your editor.

This is how I solved it😺

It worked for me too. Thanks for saving a lot of my time. I tried installing either or both ffmpeg and ffmpeg-python, but I had issues either way. One thing weird was that installing ffmpeg-python for the first time don't work, but reinstalling it for the second time works.

Mian-Muhammad-AbuBakar avatar Feb 24 '24 11:02 Mian-Muhammad-AbuBakar