Search code examples
pythonopencvanacondacondaopenh264

Anaconda cannot find openh264 library


I am trying to install openh264 to use with opencv on a jupyter notebook. I am working from the anaconda prompt within an environment on Windows 10 Pro. I am using the recommended channels found on the Anaconda website.

For every and each of them, it returns

Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:
- openh264

Current channels:
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.

I have also tried adding one channel, conda-forge, to the list of default channels:

conda config --append channels conda-forge 

and then trying installation with

conda install openh264  

but I get the same result.

A pip installation

pip install openh264    

returns

Collecting openh264 ERROR: Could not find a version that satisfies the requirement openh264 (from versions: none) ERROR: No matching distribution found for openh264

I am new to video and audio encoding and processing, but I am under the impression that OpenH264 is widely used. Any idea of what might be happening?


Solution

  • My setup is a little different (not using the Jupyter notebook) but if you run your script from the anaconda prompt (python ) you should get additional error information like this:

    "Failed to load OpenH264 library: openh264-1.4.0-win64msvc.dll
    Please check environment and/or download library from here: https://github.com/cisco/openh264/releases
    
    [libopenh264 @ 000001747d1b7280] Incorrect library version loaded
    Could not open codec 'libopenh264': Unspecified error"
    

    All I had to do to fix this was to go here: https://github.com/cisco/openh264/releases

    Then, download and extract the openh264-1.4.0-win64msvc.dll (7-zip works for bz2 decoding), and finally put the requested dll in the directory where your python script is being run.

    With the openCV videowriter object, the fourCC code you'll need is "H264", and then use an .mkv file extension when writing your video stream to file.

    I hope this helps you!