h264decoder icon indicating copy to clipboard operation
h264decoder copied to clipboard

Install failed on ubuntu22.04 with python 3.8 on ffmpeg 3.4.9

Open hs150521 opened this issue 2 years ago • 2 comments

I'm running pip install . and it went wrong, here is the output

yuanzl@yuanzl-pi5:~/h264decoder-master$ pip install .
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing /home/yuanzl/h264decoder-master
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: h264decoder
  Building wheel for h264decoder (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [69 lines of output]
      running bdist_wheel
      running build
      running build_ext
      -- The C compiler identification is GNU 9.5.0
      -- The CXX compiler identification is GNU 9.5.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.18", minimum required is "3.6")
      -- Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.8.so
      -- Performing Test HAS_FLTO
      -- Performing Test HAS_FLTO - Success
      -- Found pybind11: /home/yuanzl/.local/include (found version "2.11.1")
      Using existing pybind11 v2.11.1
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /home/yuanzl/h264decoder-master/build/temp.linux-aarch64-3.8
      [ 25%] Building CXX object CMakeFiles/h264decoderlib.dir/src/h264decoder.cpp.o
      /home/yuanzl/h264decoder-master/src/h264decoder.cpp: In constructor ‘H264Decoder::H264Decoder()’:
      /home/yuanzl/h264decoder-master/src/h264decoder.cpp:40:28: error: ‘AV_CODEC_CAP_TRUNCATED’ was not declared in this scope; did you mean ‘AV_CODEC_CAP_HARDWARE’?
         40 |   if(codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
            |                            ^~~~~~~~~~~~~~~~~~~~~~
            |                            AV_CODEC_CAP_HARDWARE
      /home/yuanzl/h264decoder-master/src/h264decoder.cpp:41:23: error: ‘AV_CODEC_FLAG_TRUNCATED’ was not declared in this scope; did you mean ‘AV_CODEC_FLAG_DROPCHANGED’?
         41 |     context->flags |= AV_CODEC_FLAG_TRUNCATED;
            |                       ^~~~~~~~~~~~~~~~~~~~~~~
            |                       AV_CODEC_FLAG_DROPCHANGED
      gmake[2]: *** [CMakeFiles/h264decoderlib.dir/build.make:76: CMakeFiles/h264decoderlib.dir/src/h264decoder.cpp.o] Error 1
      gmake[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/h264decoderlib.dir/all] Error 2
      gmake: *** [Makefile:91: all] Error 2
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/yuanzl/h264decoder-master/setup.py", line 79, in <module>
          setup(
        File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/home/yuanzl/h264decoder-master/setup.py", line 46, in run
          self.build_extension(ext)
        File "/home/yuanzl/h264decoder-master/setup.py", line 77, in build_extension
          subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
        File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for h264decoder
  Running setup.py clean for h264decoder
Failed to build h264decoder
ERROR: Could not build wheels for h264decoder, which is required to install pyproject.toml-based projects

I'm quite confused because It seems to be a incompatible question on ffmpeg, which AV_CODEC_CAP_TRUNCATED has been removed on ffmpeg 6.0, but I'm using ffmpeg 3.4.9 and I don't know how to fix that.

hs150521 avatar Jan 17 '24 12:01 hs150521

So the issue for me was that I had previously installed a newer version of ffmpeg (6.x) through a ppa and that required the newer version of libavcodec which caused this error. Once I uninstalled both and downgraded to ffmpeg 4.4.2 and libavcodec 58 (which I believe are the defaults for ubuntu 22.04?), the package compiled correctly. Had to remove the ppa, then sudo apt autoremove then sudo apt install ffmpeg. Check with ffmpeg -version and you can check the libavcodec you have installed with ls -l /usr/lib/x86_64-linux-gnu/libavcodec*

TSoli avatar Mar 26 '24 02:03 TSoli

This is probably going to be fixed with https://github.com/DaWelter/h264decoder/pull/21.

DaWelter avatar Jun 30 '24 12:06 DaWelter