imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

ffmpeg executable permission issue in linux, Runtime error: No ffmpeg could be found #45

Closed mayank10j closed 3 years ago

mayank10j commented 3 years ago

On inspecting ffmpeg executable installed after installing imageio-ffmpeg package is not readable and executable which is causing following runtime error: RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

Enclosing Dockerfile for replicating issue in linux:

FROM continuumio/miniconda3 AS build

# Install dependencies and tools
RUN DEBIAN_FRONTEND=noninteractive apt-get update -yqq && \
    apt-get upgrade -yqq && \
    apt-get install -yqq --no-install-recommends \
#    wget \
#    curl \
    libssl-dev \
    build-essential \
    apt-utils \
    zip \
    unzip \
    gcc \
    git \
    locales \
    nano \
    libgl1-mesa-glx \
    libsm6 libxext6 \
    --no-install-recommends \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /src/*.deb \
    && apt-get clean

RUN pip install imageio_ffmpeg
ENV SHELL /bin/bash

Now calling def get_ffmpeg_exe() method after importing imageio_ffmpeg causes this runtime issue. Additionally I can see ffmpeg binary ffmpeg-linux64-v4.2.2 in site-packages /opt/conda/lib/python3.8/site-packages/imageio_ffmpeg-0.4.3-py3.8-linux-x86_64.egg/imageio_ffmpeg/binaries. Manually setting permission using chmod +x ffmpeg-linux64-v4.2.2 fixes issue. This should be automatically handled by code while installing.

almarklein commented 3 years ago

Thanks for the report @mayank10j !

This surprises me a bit. The permissions are set during the packaging process, and as far as I can tell, the permissions are maintained by wheels. I just confirmed on Linux that I can do pip install imageio-ffmpeg and then run get_ffmpeg_exe() just fine.

Could there be something different in your env that causes this approach to break? Perhaps pip-installing in a conda env?

It is possible to set permissions in setup.py, but that will only work when installing from sdist ...

mayank10j commented 3 years ago

There are two differences with usual pip based environment on Linux system i can think of:

  1. Environment is manged by Conda environment.
  2. Instead of normal user, installation and running inside container is done as root user.

I can replicate this issue by building a docker container using above Dockerfile and running get_ffmpeg_exe() which fails.

almarklein commented 3 years ago

Odd

almar@almar-VirtualBox:~/dev/test$ docker run -it ffmpeg1
(base) root@8b72e3ce1e55:/# python3
Python 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import imageio_ffmpeg
>>> imageio_ffmpeg.get_ffmpeg_exe()
'/opt/conda/lib/python3.8/site-packages/imageio_ffmpeg/binaries/ffmpeg-linux64-v4.2.2'
>>> imageio_ffmpeg.get_ffmpeg_version()
'4.2.2-static'
FuriouslyCurious commented 3 years ago
almarklein commented 3 years ago

fixed the issue in the environment

For future reference, could you please explain how you fixed it or what the cause of the error was?