读取AVI视频-Matlab [英] Read avi video - Matlab

查看:115
本文介绍了读取AVI视频-Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Matlab中读取AVI文件.我根据以下链接尝试过: http://inside.mines.edu/~whoff/courses/EENG512/lectures/other/Matlab_movies.pdf :

I want to read an AVI File in Matlab. I tried it according to this link: http://inside.mines.edu/~whoff/courses/EENG512/lectures/other/Matlab_movies.pdf :

clear all
close all
movieObj = VideoReader('ap001_BL0_SP2_cam03_compressed.avi'); % open file
get(movieObj) % display all information about movie
nFrames = movieObj.NumberOfFrames; %shows 310 in my case
for iFrame=1:2:nFrames
    I = read(movieObj,iFrame); % get one RGB image
    imshow(I,[]); % Display image
end

我收到以下错误:

使用VideoReader/read时出错(第145行),请求的帧索引为超出文件末尾.

Error using VideoReader/read (line 145) The frame index requested is beyond the end of the file.

test_video_read中的错误(第9行)I = read(movieObj,iFrame);% 得到一幅RGB图像

Error in test_video_read (line 9) I = read(movieObj,iFrame); % get one RGB image

(变短)"get(movieObj)"的输出是:

(Shortened) Output from "get(movieObj)" is:

General Settings: 
   Duration = 10.3333
   Name = ap001_BL0_SP2_cam03_compressed.avi
   Type = VideoReader

Video Settings:
   BitsPerPixel = 24
   FrameRate = 30
   Height = 1280
   NumberOfFrames = 310
   VideoFormat = RGB24
   Width = 960

因此,有可能读取第一帧,因为有310可用!我可以在VLC-Player中播放AVI文件,因此应该已经安装了编解码器,对吧?

So it should be possible to read the first frame, as there are 310 available! I can play the AVI file in VLC-Player, so the codec should be already installed, right?

我正在使用Windows 7的MATLAB R2013a.请提供任何帮助,谢谢!

I'm using MATLAB R2013a, Windows 7. Can anyone please help, thank you!

推荐答案

VLC播放器是使用ffmpeg编解码器构建的.VideoReader使用Windows平台API的DirectShow和Media Foundation API,它们与ffmpeg不同.因此,如果使用VLC播放文件,则不能保证VideoReader会打开该文件.您可以做的几件事:

VLC player is built using the ffmpeg codecs. VideoReader uses DirectShow and Media Foundation API's that are Windows Platform API's and are different from ffmpeg. So, if a file plays using VLC, it is not guaranteed to be opened by VideoReader. Couple of things you can do:

  1. 可以在Windows Media Player上查看文件吗?如果是这样,则在大多数情况下,它应该与VideoReader一起使用.如果没有,则您没有合适的编解码器.尝试安装ffsdhow或K-lite编解码器包.
  2. 如果文件可在Windows Media Player上运行,但VideoReader不支持,则表明存在错误.过去对我有用的解决方法是,我安装上面提到的编解码器,然后再试一次.
  3. 如果(1)和(2)没有帮助,请使用手刹或Mirro之类的软件将文件转码为MP4,该文件可以在VideoReader上使用.

希望这会有所帮助.

迪内什

这篇关于读取AVI视频-Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆