Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

VideoCapture on file always returns false on ubuntu

6 views
Skip to first unread message

Benz huang

unread,
Oct 17, 2024, 1:23:18 AM10/17/24
to javacpp
  • Project Architecture: spring boot, gradle
  • Dependencies: org.bytedeco:opencv-platform:4.9.0-1.5.10
  • Operating system: Mac 14.7, Ubuntu 22.04.5
Code
File sourceFile = FileUtils.downloadWithRetry(videoProperties.getBaseDir(), fsFile.getRawUrl(), filesTbp.getName(), 3);
if (null == sourceFile) {
   log.warn("download video file failed, parent:{}, name:{}", filesTbp.getParent(), filesTbp.getName());
  return;
}

VideoCapture videoCapture = new VideoCapture(sourceFile.getAbsolutePath());
// check is open
if (!videoCapture.isOpened()) {
   //boolean deleted = sourceFile.delete();
   log.error("Could not open video file, parent:{}, name:{}, result:{}", filesTbp.getParent(), filesTbp.getName(), false);
   return;
}

Issue: For the same video file, isOpened is true on Mac, but false on ubuntu. How to find the false of failure or solve on Ubuntu?

Attempts to open the OpenCV logs fail when using
@Slf4j
@Configuration
public class OpenCVConfig {

@PostConstruct
public void loadOpenCV() {
System.setProperty("OPENCV_LOG_LEVEL", "DEBUG");

   // local OpenCV 
   Loader.load(org.bytedeco.opencv.opencv_java.class);
   log.info("OpenCV loaded successfully");
  }
}

Samuel Audet

unread,
Oct 17, 2024, 1:25:47 AM10/17/24
to javacpp...@googlegroups.com, Benz huang
Please try to use FFmpegFrameGrabber instead of VideoCapture
Reply all
Reply to author
Forward
0 new messages