kyamagu / mexopencv

Collection and a development kit of matlab mex functions for OpenCV library
http://kyamagu.github.io/mexopencv
Other
659 stars 318 forks source link

videocapture read in empty #421

Closed yuyuwang closed 5 years ago

yuyuwang commented 5 years ago

Hello~ when i run the code Video = cv.VideoCapture('000.MTS', 'API','FFMPEG'); The values of variable in Video are 0 except Video.id My matlab 2017a, OpenCV 3.3.1 How to solve the problem?

amroamroamro commented 5 years ago

Try:

vid = cv.VideoCapture('000.MTS', 'API','FFMPEG');
if ~vid.isOpened()
    error('failed to open video file');
end

Failure means one of these things:

I'm not familiar with *.mts format, so if it's a decoding issue, perhaps you can convert it to another codec/container, say H.264/MP4, using an external tool.

http://amroamroamro.github.io/mexopencv/matlab/cv.VideoCapture.html

yuyuwang commented 5 years ago

I tried

vid = cv.VideoCapture('000.MTS', 'API','FFMPEG');
if ~vid.isOpened()
    error('failed to open video file');
end

it failed to open both mp4 and mts format.

then i checked the output of cv.getBuildInformation

Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      NO
      avcodec:                   YES (ver 57.107.100)
      avformat:                  YES (ver 57.83.100)
      avutil:                    YES (ver 55.78.100)
      swscale:                   YES (ver 4.8.100)
      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

does it mean opencv was not built with FFmpeg support?

amroamroamro commented 5 years ago

It seems so, yes.

    FFMPEG:                      NO

That says that the FFmpeg backend is not enabled in your OpenCV build! So the question is how did you install/build opencv?

You might wanna check the wiki for help on building opencv/opencv_contrib from source: https://github.com/kyamagu/mexopencv/wiki/Installation-%28Linux%2C-MATLAB%2C-OpenCV-3%29 (the instructions are for version 3.4.1)

yuyuwang commented 5 years ago

I have solved the problem. Thanks for your help!