也谈matlab中读取视频的一个重要函数mmreader

在matlab中输入help mmreader来查阅一下该函数,有如下信息:

MMREADER Create a multimedia reader object.
 
    OBJ = MMREADER(FILENAME) constructs a multimedia reader object, OBJ, that
    can read in video data from a multimedia file.  FILENAME is a string
    specifying the name of a multimedia file.  There are no restrictions
    on file extensions.  By default, MATLAB looks for the file FILENAME on
    the MATLAB path.
 
    If the object cannot be constructed for any reason (for example, if the
    file cannot be opened or does not exist, or if the file format is not
    recognized or supported), then MATLAB throws an error.
 
    OBJ = MMREADER(FILENAME, 'P1', V1, 'P2', V2, ...) 
    constructs a multimedia reader object, assigning values V1, V2, etc. to the
    specified properties P1, P2, etc.
 
    If an invalid property name or property value is specified, MATLAB throws
    an error and the object is not created.  Note that the property value pairs
    can be in any format supported by the SET function, e.g. parameter-value
    string pairs, structures, or parameter-value cell array pairs.

下面给出两个简单的应用:

  1. clear
  2. clc
  3. cd('C:\Documents and Settings\Administrator\桌面\matlab');
  4. % .avi必须是无损压缩的. matlab读取发现,视频尺寸为176*144
  5. fileName = 'ntia_wfall-qcif_original.avi';
  6. % mm不表示美眉,而表示multimedia. obj是一个对象
  7. obj = mmreader(fileName);
  8. % 读取所有的帧数据
  9. vidFrames = read(obj);
  10. % 帧的总数
  11. numFrames = obj.numberOfFrames;
  12. % 读取数据
  13. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧
  14. for k = 1 : numFrames
  15. mov(k).cdata = vidFrames(:,:,:,k);
  16. mov(k).colormap = [];
  17. end
  18. % 在matlab中播放视频
  19. movie(mov);
    1. clear
    2. clc
    3. cd('C:\Documents and Settings\Administrator\桌面\matlab');
    4. % 有损压缩的.mpg视频. matlab读取后发现,视频大小为352*288
    5. fileName = '功夫熊猫_盖世五侠的秘密.mpg';
    6. % mm不表示美眉,而表示multimedia. obj是一个对象
    7. obj = mmreader(fileName);
    8. begin = 1001;
    9. % 读取[begin begin + 99]中的100帧数据
    10. vidFrames = read(obj, [begin begin + 99]);
    11. % 读取数据
    12. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧
    13. for k = 1 : 100
    14. mov(k).cdata = vidFrames(:,:,:,k);
    15. mov(k).colormap = [];
    16. end
    17. % 在matlab中播放视频

最新文章

  1. Java—反射
  2. codevs 4163 hzwer与逆序对
  3. byte 读写文件
  4. 基于WAMP的Crossbario 安装入门
  5. 如何扩展分布式日志组件(Exceptionless)的Webhook事件通知类型?
  6. goldengate同源一目标+多表和同源多目标+多表
  7. ZooKeeper系列(6):ZooKeeper的伸缩性和Observer角色
  8. weex用阿里矢量图
  9. JS将日期转化为unix时间戳
  10. CentOS6.5安装php7+nginx+mysql实现安装WordPress
  11. android listview使用自定义的adapter没有了OnItemClickListener事件解决办法
  12. popViewControllerAnimated 后的刷新问题
  13. php+ajax+jquery 定时刷新页面数据
  14. centos 7 下安装haproxy
  15. 2017.10.15 解析Java中抽象类和接口的区别
  16. hdu 2993 斜率dp
  17. AC日记——Housewife Wind poj 2763
  18. 【Codeforces】879D. Teams Formation 思维+模拟
  19. Resin Thread Dump
  20. 常用JavaScript代码库(又名:WFang.js)

热门文章

  1. 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem F. Format
  2. WebSphere Application Server诊断和调优
  3. java结合testng,利用XML做数据源的数据驱动示例
  4. Linux的压缩/解压缩文件处理 zip & unzip
  5. php 计算本周星期一、本月第一天 本月最后一天 下个月第一天
  6. 常用的Redis客户端的并发模型(转)
  7. Git回滚merge操作
  8. LoadRunner脚本增强技巧之手动关联
  9. bootstrap 中的静态模式的控制按钮上的一个坑
  10. idea Class<>表示的含义