Ask Your Question

Can't open file when using VideoFileSource

asked 2018-07-13 05:33:02 -0500

updated 2018-07-13 05:38:46 -0500

berak gravatar image

hi guy

I have used the code in Java and C++ (NDK in Android). In my code have used VideoFileSource read video file. But when I ran, below error has occurred.

     E/cv::error(): OpenCV(3.4.1) Error: No Error (can't open file: ) in virtual void cv::videostab::{anonymous}::VideoFileSourceImpl::reset(), file /build/master_pack-android/opencv/modules/videostab/src/frame_source.cpp, line 71


        if (!vc.isOpened())
            CV_Error(0, "can't open file: " + path_); //line 71

How to fix this bugs?

edit retag flag offensive close merge delete


also: your filename seems to be empty: (can't open file: )

berak gravatar imageberak ( 2018-07-13 05:55:12 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2018-07-13 05:50:54 -0500

berak gravatar image

unfortunately, there is no real backend (like ffmpeg or gstreamer) for video decoding on android, you can only use MJPG encoded avi files.

the error means, that your file could not be opened/decoded.

edit flag offensive delete link more


How to link FFmpeg? In lib has not FFmpeg? I have used java ( the same code has occurred.)

Using lib OpenCV in NDK has the same error.

monxarat gravatar imagemonxarat ( 2018-07-13 06:21:14 -0500 )edit

no, the opencv4android sdk does not have ffmpeg. (no matter if you use c++ or java)

and we can't help you with javaCV, sorry.

berak gravatar imageberak ( 2018-07-13 06:49:50 -0500 )edit

No no, In my code, I have used OpenCV download form OpenCV page.

My codes using OpenCV for Android using NDK.

//1 prepear the input video and check it string input
        Ptr<VideoFileSource> source = makePtr<VideoFileSource>(sourcePath);Error here.
        cout << "Frame count (rough): " << source -> count() << endl;

        // 2 Prepare the motion estimator
        // first prepare the motion the estimation builder RANSAC L2;
        Ptr<MotionEstimatorRansacL2> est = makePtr<MotionEstimatorRansacL2>(MM_AFFINE);

        RansacParams ransac = est->ransacParams();
        ransac.size = RANSAC_SIZE;
        ransac.thresh = RANSAC_THESH;
        ransac.eps = RANSAC_EPS;

monxarat gravatar imagemonxarat ( 2018-07-13 07:03:44 -0500 )edit

Error here.

that will call the code you show in you your question above. and the error says: the sourcepath is empty.

(the video codec problems will start only later)

berak gravatar imageberak ( 2018-07-13 07:57:13 -0500 )edit

No, sourcepath not empty

E/cv::error(): OpenCV(3.4.1) Error: No Error (can't open file: /storage/emulated/0/DCIM/Camera/patio.mp4) in virtual void cv::videostab::{anonymous}::VideoFileSourceImpl::reset(), file /build/master_pack-android/opencv/modules/videostab/src/frame_source.cpp, line 71
monxarat gravatar imagemonxarat ( 2018-07-13 12:37:26 -0500 )edit

my code

String dcimFolder = StorageManager.getDCIMFolder();
        File videoFile = new File(dcimFolder, "Camera/patio.mp4");
        String outpath = new File(dcimFolder, "Camera/stab_patio.mp4").getAbsolutePath();
        if (videoFile.exists()) {
            VideoStab videoStab = VideoStab.getInstance();
            Log.e(">>>File Exist", videoFile.exists() + " canOpen:" + videoFile.canRead() + " path: " + videoFile.getAbsoluteFile());
monxarat gravatar imagemonxarat ( 2018-07-13 12:38:03 -0500 )edit

Log check file video

07-14 02:33:06.233 E/>>>File Exist: true canOpen:true path: /storage/emulated/0/DCIM/Camera/patio.mp4
monxarat gravatar imagemonxarat ( 2018-07-13 12:41:07 -0500 )edit


How to do this.

monxarat gravatar imagemonxarat ( 2018-07-17 01:39:13 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-07-13 05:33:02 -0500

Seen: 11 times

Last updated: Jul 13