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 --- working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h (limited to 'working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h') diff --git a/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h b/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h new file mode 100644 index 0000000..4c8f96e --- /dev/null +++ b/working/ffmpeg_fas-wrapper/ffmpeg-fas_wrapper.h @@ -0,0 +1,55 @@ +#ifndef ffmpeg_fas_wrapper_H +#define ffmpeg_fas_wrapper_H + +#include +#include +#include "ffmpeg_fas.c" + + +namespace ffmpeg_fas { + class decoder + { + public: + decoder(){ + fas_initialize(FAS_TRUE,FAS_RGB24); + loaded=false; + framerate=0.0f; + numFrames=0; + } + bool open(std::string& filename){ + fas_error_type e=fas_open_video(&context,filename.c_str()); + if (e==FAS_SUCCESS){ + loaded=true; + framerate=(((float)context->format_context->streams[context->stream_idx]->r_frame_rate.num)/((float)context->format_context->streams[context->stream_idx]->r_frame_rate.den)); + numFrames=context->format_context->streams[context->stream_idx]->nb_frames; + if (numFrames<1){ + //some codecs don't keep this info in the header + numFrames = (int)(( context->format_context->duration / (double)AV_TIME_BASE ) * framerate ); + //this approach still doesn't seem to give quite the right answer- comes out a little too big + //could alternatively just redefine the length if the reader fails + } + } + else { + std::cerr<<"ffmpeg_fas ERROR: "<