4

I managed to install OpenCV 3.1 using conda and Python 3.5 and everything seems to work fine.

However, when trying to import a video file via ffmpeg I get this:

import numpy as np
import cv2

cap = cv2.VideoCapture('data\vtest.avi')
cap.read()

#(False, None)

When using still images or my laptop webcam it works (notice that the VideCapture returns None). Obviously, something is wrong with ffmpeg.

I have tried a couple of things:

  1. Install ffmpeg binaries in my environment/PATH (works fine separately but apparently OpenCV cannot call it since it looks for specific dlls).
  2. Move to the bin folder (which is in my path as well) the dlls from the compiled version in sourceforge:

    opencv_ffmpeg310_64.dll

    opencv_ffmpeg310.dll

Neither of the two options worked. Any ideas?

FZNB
  • 2,703
  • 3
  • 17
  • 17

2 Answers2

3

The latest conda-forge build contains FFMPEG now. Having miniconda or Anaconda in your computer, everything will be installed by running in the cmd or terminal:

conda install -c conda-forge opencv ffmpeg

Alternatively, menpo's channel recipes can also be used:

conda install -c menpo opencv3 ffmpeg
FZNB
  • 2,703
  • 3
  • 17
  • 17
  • Hello! Installing both packages actually doesn't solve the problem. The result of `cap.isOpened()` is still `False` – VladVin Aug 15 '17 at 21:54
  • I added the ffmpeg explicitly in case the dependencies are not well resolved, try it now. – FZNB Aug 16 '17 at 19:21
  • Any idea why this doesn't work when I create an executable with `cx_freeze`? – Joe T. Boka Jun 17 '18 at 01:29
  • What is the difference between `conda install -c conda-forge opencv ffmpeg` and `conda install -c conda-forge opencv` ? – Rami Alloush Nov 26 '19 at 20:45
  • There are different anaconda channels, but packages shouldn't differ. I usually prefer conda-forge as it is supported by the community – FZNB Dec 02 '19 at 09:30
-2

The conda version of OpenCV is not compiled with ffmpeg. I too have struggled with this problem endlessly. The pip version is not compiled with ffmpeg either. The best advice I have is to compile OpenCV with ffmpeg yourself, that is the only painless and stable way that I have found.

N Ruiz
  • 9
  • 2