From f9694b7d4f1648a0fa984e7cc428bbc9eea86ca0 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 11 Sep 2013 16:11:47 +0100 Subject: ffms2 library for video loader --- rotord/src/libavwrapper.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'rotord/src/libavwrapper.h') diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index d30ea95..870815f 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -69,6 +69,8 @@ extern "C" { #include #include +#include + namespace libav { @@ -154,6 +156,68 @@ namespace libav { }; + class ffms2_decoder + { + public: + ffms2_decoder(){ + maybeInitFFMpegLib(); + pixfmts[0] = FFMS_GetPixFmt("rgb24"); + pixfmts[1] = -1; + h=0; + w=0; + videosource=NULL; + loaded=false; + errinfo.Buffer = errmsg; + errinfo.BufferSize = sizeof(errmsg); + errinfo.ErrorType = FFMS_ERROR_SUCCESS; + errinfo.SubType = FFMS_ERROR_SUCCESS; + } + ~ffms2_decoder(){ + cleanup(); + } + void cleanup(); + bool open(const std::string& filename); + float getFrameRate(){ + if (loaded) return (((float)videoprops->FPSNumerator)/((float)videoprops->FPSDenominator)); + else return -1.0f; + } + int getNumberOfFrames(){ + if (loaded) return videoprops->NumFrames; + else return -1; + } + int getNumberOfChannels(){ + return 3; //this is what we convert to + } + int getWidth(){ + return w; + } + int getHeight(){ + return h; + } + bool fetchFrame(int width,int height,int wanted){ + if (FFMS_SetOutputFormatV2(videosource, pixfmts, width, height, FFMS_RESIZER_BICUBIC, &errinfo)) { + std::cerr<<"ffmpegsource: "<NumFrames, &errinfo); + if (frame == NULL) { + std::cerr<<"ffmpegsource: "<