尝试加载.mp4视频无法使用开放式简历

时间:2017-02-18 17:40:13

标签: opencv video ffmpeg video-capture

我在我的linux服务器上安装了ffmpeg和opencv,就像那样:

git clone <ffmpeg_git_repositiory>
cd FFmpeg
./configure --enable-shared
make
sudo make install

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

git clone <opencv_git_repositiory>
cmake <path to="" the="" opencv="" source="" directory="">
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

我写了一个小小的Python脚本:

import cv2
cap = cv2.VideoCapture('video.mp4')
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

但我无法加载该视频,而且total_frames总是为0。

我做了一些研究,为什么这不起作用,发现大量的答案尝试了很多方法来安装它,但它对我没有用。

我做错了什么?我错过了一些细节吗?

我真的很生气并安装它

修改

cmake opencv时,它显示了我:

--   Video I/O:                                                              
--     DC1394 1.x:                  NO                                       
--     DC1394 2.x:                  YES (ver 2.2.1)                          
--     FFMPEG:                      YES                                      
--       avcodec:                   YES (ver 57.80.101)                      
--       avformat:                  YES (ver 57.66.102)                      
--       avutil:                    YES (ver 55.47.100)                      
--       swscale:                   YES (ver 4.3.101)                        
--       avresample:                YES (ver 1.0.1)                          
--     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                                       
--     gPhoto2:                     NO

所以ffmpeg应该可用,对吧?

编辑2:

重新安装新的新VM后,我收到此错误:

[mp3 @ 0x1dbb2a0] Header missing
[mp3 @ 0x1dbb2a0] Header missing
Unable to stop the stream: Inappropriate ioctl for device
(python:17171): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

0 个答案:

没有答案