kkroening/ffmpeg-python

[Errno 2] No such file or directory: 'ffprobe'

etomarat opened this issue · 3 comments

Hello! i have brew install ffmpeg and ffprobe work in terminal. But i have
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'
With this code:

from tempfile import NamedTemporaryFile
import ffmpeg


class Video:
    def __init__(self, file_name: str, file_content: bytes) -> None:
        self.file_name = file_name
        self.input_content = file_content
        self.save_temp()

    def save_temp(self) -> None:
        self.tmp_file = NamedTemporaryFile()
        self.tmp_file.write(self.input_content)

    def close_temp(self) -> None:
        self.tmp_file.close()

    async def compress(self) -> bytes:
        print(self.tmp_file.name)
        info = ffmpeg.probe(self.tmp_file.name)
        print(info)

Full traceback:

Traceback (most recent call last):
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette_exporter/middleware.py", line 232, in __call__
    await self.app(scope, receive, wrapped_send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
    return await dependant.call(**values)
  File "/Users/etomarat/Projects/mymons/site-backend/./papazaim/site_api/video/routes.py", line 47, in upload_video_confirmation
    await video.compress()
  File "/Users/etomarat/Projects/mymons/site-backend/./papazaim/site_api/video/video.py", line 20, in compress
    info = ffmpeg.probe(self.tmp_file.name)
  File "/Users/etomarat/Projects/mymons/site-backend/.venv/lib/python3.10/site-packages/ffmpeg/_probe.py", line 20, in probe
    p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'

How can i fix this problem? Thank you!

This ffprobe /tmp/tmpecdjgoo2 output for my tempfile in terminal

➜  ~ ffprobe /tmp/tmpecdjgoo2
ffprobe version 6.0 Copyright (c) 2007-2023 the FFmpeg developers
  built with Apple clang version 14.0.0 (clang-1400.0.29.202)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/tmpecdjgoo2':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2023-04-25T14:57:34.000000Z
    com.apple.quicktime.location.accuracy.horizontal: 19.167607
    com.apple.quicktime.location.ISO6709: +40.1732+044.5219+991.410/
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone XR
    com.apple.quicktime.software: 16.1.1
    com.apple.quicktime.creationdate: 2023-04-25T18:57:34+0400
  Duration: 00:00:10.63, start: 0.000000, bitrate: 12051 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080, 11784 kb/s, 60.02 fps, 60 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2023-04-25T14:57:34.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : HEVC
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 180 kb/s (default)
    Metadata:
      creation_time   : 2023-04-25T14:57:34.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2023-04-25T14:57:34.000000Z
      handler_name    : Core Media Metadata
  Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    Metadata:
      creation_time   : 2023-04-25T14:57:34.000000Z
      handler_name    : Core Media Metadata
  Stream #0:4[0x5](und): Data: none (mebx / 0x7862656D), 69 kb/s (default)
    Metadata:
      creation_time   : 2023-04-25T14:57:34.000000Z
      handler_name    : Core Media Metadata
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3
Unsupported codec with id 0 for input stream 4

I download https://evermeet.cx/ffmpeg/ffprobe-6.0.7z and add it to my $PATH variable. It has no effect. Where the ffmpeg-python find ffprobe?

Understood the problem. I was doing os.environ.clear() and forgot about it