Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCapture cannot open video file in Java #4974

Closed
opencv-pushbot opened this issue Jul 27, 2015 · 18 comments
Closed

VideoCapture cannot open video file in Java #4974

opencv-pushbot opened this issue Jul 27, 2015 · 18 comments

Comments

@opencv-pushbot
Copy link
Contributor

Transferred from http://code.opencv.org/issues/4298

|| Bahramuidn Adil on 2015-04-28 05:17
|| Priority: High
|| Affected: branch 'master' (3.0-dev)
|| Category: java bindings
|| Tracker: Bug
|| Difficulty: Medium
|| PR: 
|| Platform: x64 / Windows

VideoCapture cannot open video file in Java


History

Bahramuidn Adil on 2015-04-28 05:20
OpenCV 3.0 VideoCapture doesn't open video file in Java, but there is no problem if open camera.
-   Target version set to 3.0
Maksim Shabunin on 2015-04-28 12:35
-   Category set to java bindings
@padilla0
Copy link

padilla0 commented Nov 3, 2015

any solution?

@medloh
Copy link

medloh commented Nov 6, 2015

I was able to open several .mp4 files using opencv 3.0 java bindings to VideoCapture, and successfully step through their frames and get metadata about each frame.

@padilla0
Copy link

padilla0 commented Nov 9, 2015

i can see your code?

@medloh
Copy link

medloh commented Nov 9, 2015

Using OpenCV 3.0 on windows:

        Mat matOrig = new Mat();
        VideoCapture capture = new VideoCapture("resources/Hummingbird.MP4");
        if( capture.isOpened()){
            while (true){  
                capture.read(matOrig);  
                // get some meta data about frame.              
                double fps = capture.get(Videoio.CAP_PROP_FPS);
                double frameCount = capture.get(Videoio.CAP_PROP_FRAME_COUNT);
                double h = capture.get(Videoio.CAP_PROP_FRAME_HEIGHT);
                double w = capture.get(Videoio.CAP_PROP_FRAME_WIDTH);
                double posFrames = capture.get(Videoio.CAP_PROP_POS_FRAMES);
                double posMsec = capture.get(Videoio.CAP_PROP_POS_MSEC);
                double speed = capture.get(Videoio.CAP_PROP_SPEED);
                if( !matOrig.empty() ) {
                    // do stuff
                }
            }
        }

@padilla0
Copy link

i don't know if the problem is my *.mp4 *.avi or *.mpg file but capture.isOpened() return false , any sugestion?

@medloh
Copy link

medloh commented Nov 11, 2015

Try opening a few other video files, verify you're using the right path in the VideoCapture constructor. What OS/Platform/JDK versions are you using?

@padilla0
Copy link

ok, i'm with windows/ java 1.7 but don't worry, i load my files now with javacv , using FFmpegFrameGraber

@elitcenk
Copy link

elitcenk commented Dec 8, 2015

You are missing the loading ffmpeg dll. If use 64 add opencv_ffmpeg300_64.dll. If you use 32 add opencv_ffmpeg300.dll. Add this the your code.

System.loadLibrary("opencv_ffmpeg300_64");

@alalek
Copy link
Member

alalek commented Dec 8, 2015

System.loadLibrary is not required.
Just put opencv_ffmpeg*.dll file(s) near opencv_java*.dll or update PATH environment variable which should point to opencv_ffmpeg*.dll

@SonnyBao
Copy link

I have same issue on Ubuntu.
I've tried to compile ffmpeg from source as shared lib. It creates some libav*.so, but OpenCV Java code still cannot open the mp4/avi file with no errror or warning.
What should I do?

@iamdarknight
Copy link

Add to path and restart terminal C:\opencv\opencv\build\x64\vc12\bin

@aritra1994
Copy link

aritra1994 commented Oct 3, 2017

I have issue on Ubuntu 17.04. When I amtrying to run my program it shows message

(DEBUG) try_init_v4l2 VIDIOC_QUERYCAP "/home/aritra/workspace/oopencv/horror.mp4": Inappropriate ioctl for device
Unable to stop the stream: Inappropriate ioctl for device

What should I do now?

@alalek
Copy link
Member

alalek commented Oct 3, 2017

There is missing backends for Video I/O in your OpenCV build.
Usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org

@aritra1994
Copy link

I have found that my video is not opening by VideoCapture. An the question asked here remain not appropriately answered
@alalek can you suggest me anything?

@alalek
Copy link
Member

alalek commented Oct 3, 2017

This tracker is for issues and bugs that needs fix in OpenCV. We don't process help requests here or investigate issues on users side.
Again, you need proper build of OpenCV with enabled Video I/O backends (ffmpeg or gstreamer). Refer to OpenCV build/installation tutorials at first. You need configuration something like this:

--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 54.35.1)
--       avformat:                  YES (ver 54.20.4)
--       avutil:                    YES (ver 52.3.0)
--       swscale:                   YES (ver 2.1.1)
--       avresample:                NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    NO/YES
--     XIMEA:                       NO
--     Xine:                        NO
--     Intel Media SDK:             NO
--     gPhoto2:                     NO

@aritra1994
Copy link

I have configuration like this

Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.64.101)
--       avformat:                  YES (ver 57.56.101)
--       avutil:                    YES (ver 55.34.101)
--       swscale:                   YES (ver 4.2.100)
--       avresample:                YES (ver 3.1.0)
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     Aravis SDK:                  NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.12.3) / libv4l2 (ver 1.12.3)
--     XIMEA:                       NO
--     Xine:                        NO
--     gPhoto2:                     NO

But still getting message @alalek

Failed to query video capabilities: Inappropriate ioctl for device
libv4l2: error getting capabilities: Inappropriate ioctl for device
VIDEOIO ERROR: V4L: device /home/aritra/workspace/oopencv/horror.mp4: Unable to query number of channels

@DanielEColi
Copy link

@aritra1994 I met similar questions like you when I try to open an mp4 video in an android app. But I failed in the step below:
-- Check if the system is big endian - little endian
-- Found ZLIB: F:/AndroidDev/android-ndk-r10d/platforms/android-21/arch-arm64/usr/lib/libz.so (found suitable version "1.2.3", minimum required is "1.2.3")
-- Checking for modules 'libavcodec;libavformat;libavutil;libswscale'
-- No package 'libavcodec' found
-- No package 'libavformat' found
-- No package 'libavutil' found
-- No package 'libswscale' found
-- Checking for module 'libavresample'
-- No package 'libavresample' found

-- Video I/O:
-- FFMPEG: YES (prebuilt binaries)
-- avcodec: NO
-- avformat: NO
-- avutil: NO
-- swscale: NO
-- avresample: NO

could you help me to get the result like you? I mean like below:
-- FFMPEG: YES
-- avcodec: YES (ver 57.64.101)
-- avformat: YES (ver 57.56.101)
-- avutil: YES (ver 55.34.101)
-- swscale: YES (ver 4.2.100)
-- avresample: YES (ver 3.1.0)

@rajithabhanuka
Copy link

Hi all,

I'm also facing the same issue,

on my mac code is working
windows also working

but once I put it to ec2 it is not working.

if (cap.isOpened()) {} always false, appreciate your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants