MATLAB工具包mmread函数mmread.zip


MATLAB工具包mmread函数mmread.zip
资源截图
代码片段和文件信息
/***************************************************
This is the main Grabber code.  It uses AVbin and ffmpeg
to capture video and audio from video and audio files.

The code supports any number of audio or video streams and
is a cross platform solution to replace DDGrab.cpp.

This code was intended to be used inside of a matlab interface
but can be used as a generic grabber class for anyone who needs
one.

Copyright 2008 Micah Richert

This file is part of mmread.
**************************************************/

#ifdef MATLAB_MEX_FILE
#include “mex.h“
#define FFprintf(...) mexPrintf(__VA_ARGS__)
#else
#define FFprintf(...) printf(__VA_ARGS__)
#endif

//#ifndef mwSize
//#define mwSize int
//#endif

#define DEBUG 0

extern “C“ {
#include 
#include 

struct _AVbinFile {
    AVFormatContext *context;
    AVPacket *packet;
};

struct _AVbinStream {
int type;
AVFormatContext *format_context;
AVCodecContext *codec_context;
AVframe *frame;
};
}

#include 
#include 
#include 
#include 
using namespace std;

#include 
#include 
#include 

map keyframes;
unsigned int startDecodingAt;

class Grabber
{
public:
Grabber(bool isAudio AVbinStream* stream bool trySeeking double rate int bytesPerWORD AVbinStreamInfo info AVbinTimestamp start_time)
{
this->stream = stream;
frameNr = 0;
packetNr = 0;
done = false;
this->bytesPerWORD = bytesPerWORD;
this->rate = rate;
startTime = 0;
stopTime = 0;
this->isAudio = isAudio;
this->info = info;
this->trySeeking = trySeeking;
this->start_time = start_time>0?start_time:0;
};

~Grabber()
{
// clean up any remaining memory...
if (DEBUG) FFprintf(“freeing frame data...
“);
for (vector::iterator i=frames.begin();i != frames.end(); i++) free(*i);
}

AVbinStream* stream;
AVbinStreamInfo info;
AVbinTimestamp start_time;

vector frames;
vector frameBytes;
vector frameTimes;

vector frameNrs;

unsigned int frameNr;
unsigned int packetNr;
bool done;
bool isAudio;
bool trySeeking;

int bytesPerWORD;
double rate;
double startTime stopTime;

int Grab(AVbinPacket* packet)
{
if (done) return 0;
if (!packet->data) return 1;

frameNr++;
packetNr++;
if (DEBUG) FFprintf(“frameNr %d %d %d
“frameNrpacketNrpacket->size);
int offset=0 len=0;
double timestamp = (packet->timestamp-start_time)/1000.0/1000.0;
if (DEBUG) FFprintf(“time %lld %lld %lf
“packet->timestampstart_timetimestamp);

// either no frames are specified (capture all) or we have time specified
if (stopTime)
{
if (isAudio)
{
// time is being used...
if (timestamp >= startTime)
{
// if we‘ve reached the start...
offset = max(0((int)((startTime-ti

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       28788  2009-10-15 20:28  FFGrab.cpp
     文件       44571  2009-10-15 19:49  FFGrab.mexa64
     文件       42230  2009-10-15 20:06  FFGrab.mexglx
     文件       39196  2009-10-15 20:20  FFGrab.mexmac
     文件       42192  2009-10-15 20:20  FFGrab.mexmaci
     文件       39328  2009-10-15 20:20  FFGrab.mexmaci64
     文件      137998  2009-10-15 20:14  FFGrab.mexw32
     文件      756917  2009-11-12 19:11  FFGrab.mexw64
     文件     3077178  2009-05-18 18:37  avbin.dll
     文件     4660639  2009-05-19 18:44  avbin64.dll
     文件     9536816  2009-05-18 15:20  libavbin.dylib
     文件     4326671  2009-09-25 19:35  libavbin.so
     文件     4326470  2009-10-10 03:34  libavbin.so.32
     文件     3711574  2009-10-10 03:44  libavbin.so.64
     文件       10131  2007-07-28 02:24  mexDDGrab.cpp
     文件       77824  2008-10-13 14:36  mexDDGrab.dll
     文件       77824  2008-10-13 14:36  mexDDGrab.mexw32
     文件      106496  2008-04-28 19:12  mexDDGrab.mexw64
     文件       25976  2009-10-15 20:08  mmread.m
     文件        3205  2008-12-02 02:36  processframe.m
     文件        1313  2014-02-12 12:59  license.txt

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)