Ask Your Question
0

Can't open file when using VideoFileSource

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

monxarat gravatar image

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

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.

Error
     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

frame_source.cpp

#ifdef HAVE_OPENCV_VIDEOIO
        vc.release();
        vc.open(path_);
        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

Comments

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

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

1 answer

Sort by » oldest newest most voted
0

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

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

Comments

How to link FFmpeg? In lib has not FFmpeg? I have used java (https://github.com/bytedeco/ the same code has occurred.)

Using lib OpenCV in NDK has the same error.

monxarat gravatar imagemonxarat ( 2018-07-13 06:21:14 -0600 )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 -0600 )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;

        est->setRansacParams(ransac);
        est->setMi
monxarat gravatar imagemonxarat ( 2018-07-13 07:03:44 -0600 )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 -0600 )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 -0600 )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());
            videoStab.videoStab(
                    videoFile.getAbsolutePath(),
                    outpath);
        }
monxarat gravatar imagemonxarat ( 2018-07-13 12:38:03 -0600 )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 -0600 )edit

@break

How to do this.

monxarat gravatar imagemonxarat ( 2018-07-17 01:39:13 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 369 times

Last updated: Jul 13 '18