2

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?

InverniE
  • 598
  • 1
  • 7
  • 21

1 Answers1

6

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!

Flame
  • 6,663
  • 3
  • 33
  • 53
  • I tried all these steps but still the video saved is 0 bytes? The image is being saved fine but video in h264 does not save. If I save with xvid then it saves fine. Can you guide me what the problem could be. – Imran Oct 27 '20 at 13:06
  • @Imran Have you checked the Anaconda prompt after placing the correct file. We need to place the actual file requested in the error (might not be openh264-1.4.0-win64msvc.dll). You should get something like "OpenH264 Video Codec provided by Cisco Systems, Inc." after that. That is what I got after placing the correct file requested in the error (openh264-1.8.0-win64.dll) as per above answer. – Prabath Jan 24 '21 at 15:07
  • @Prabath I tried both latest one 2.1 and also 1.4.0 but both did not work. I do not get any error but at the end video is also not saved. I am still searching for the solution but still not able to find it. If anyone knows please share it with me – Imran Jan 28 '21 at 12:48
  • Can you please share the full code and Anaconda shell output with version details ? – Prabath Jan 28 '21 at 15:21