diff options
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 29 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 2 |
2 files changed, 29 insertions, 2 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index d9207bb..26523fc 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -32,7 +32,32 @@ void libav::maybeInitFFMpegLib() bool libav::video_decoder::open(const std::string& filename){ Mutex::ScopedLock lock(mutex); loaded=false; - FFMS_Index *index = FFMS_MakeIndex(filename.c_str(), 0, 0, NULL, NULL, FFMS_IEH_IGNORE, NULL, NULL, &err); + + //first check if an index object exists + Poco::StringTokenizer tokens(filename,"."); + string idxfile=""; + for (int i=0;i<tokens.count()-1;i++){ + idxfile+=tokens[i]; + idxfile+="."; + } + idxfile+="idx"; + Poco::File f=Poco::File(idxfile); + bool makeindex=true; + FFMS_Index *index; + if (f.exists()) { + index=FFMS_ReadIndex(idxfile.c_str(),&err); + if (index) { + cerr<<"FFMS2: loaded index "<<idxfile<<endl; + if (FFMS_IndexBelongsToFile(index,filename.c_str(),&err)==0){ + makeindex=false; + } + } + } + if (makeindex) { + cerr<<"FFMS2: created index "<<idxfile<<endl; + index = FFMS_MakeIndex(filename.c_str(), 0, 0, NULL, NULL, FFMS_IEH_IGNORE, NULL, NULL, &err); + FFMS_WriteIndex(idxfile.c_str(),index,&err); + } if (index == NULL) { std::cerr<<"ffmpegsource: "<<err.Buffer<<std::endl; return false; @@ -61,7 +86,7 @@ bool libav::video_decoder::open(const std::string& filename){ int framenumber = 0; /* valid until next call to FFMS_GetFrame* on the same video object */ - std::cerr<<"ffmpegsource: successfully opened "<<filename<<std::endl; + //std::cerr<<"ffmpegsource: successfully opened "<<filename<<std::endl; loaded=true; return loaded; } diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index bf073fc..0de9e74 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -8,6 +8,8 @@ #include "Poco/Mutex.h" #include "Poco/ScopedLock.h" +#include "Poco/StringTokenizer.h" +#include "Poco/File.h" extern "C" { #include <libavcodec/avcodec.h> |
