#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: "<