twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't initialize VIdeoCapture from file

111raigeki opened this issue · comments

Hello, I am trying to open a video using VideoCapture::from_file, but I can't get it to read the file properly. The project builds without any issues, but is_opened doesn't return true:

let mut cam = videoio::VideoCapture::from_file("data/test_vid.mp4", videoio::CAP_ANY)?;

let opened = videoio::VideoCapture::is_opened(&cam)?;//always false independent of file path or file format 

I've tried to do the same in python (3.10, opencv-python 4.9.0) and it works just fine. Capturing video from webcam also works fine.

Information:

  1. os: Mint 21.2
  2. way to install opencv: manual build (cmake)
  3. opencv version: 4.9.0-dev
  4. rustc version: 1.76.0 (07dca489a 2024-02-04)
  5. crate version: 0.88.8

It can be that OpenCV is built without mp4 support for example, but python is using the different OpenCV version that has this support. Please also post cargo build -vv after doing cargo clean, it contains a lot of helpful debug information that might aid in tracking the source of the issue down.

The codecs were indeed the issue - for some reason opencv did not recognize ffmpeg. Thank you for help.

The codecs were indeed the issue - for some reason opencv did not recognize ffmpeg. Thank you for help.

@111raigeki
I have the same problem, what codecs did you need to install?