diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-10-24 15:24:55 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-10-24 15:24:55 +0100 |
| commit | 9fc8a2e7b770339b72c080cfa510c461706fe43c (patch) | |
| tree | cf19dc660d7ba1892bda5c95a76ac5d1d28b112a /rotord/src | |
| parent | 525780ac886baf7ce3d9f186149f7717717c9e3a (diff) | |
catch non existent file in patchbay json video loader
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index 26523fc..2ee9985 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -33,15 +33,25 @@ bool libav::video_decoder::open(const std::string& filename){ Mutex::ScopedLock lock(mutex); loaded=false; + Poco::File f=Poco::File(filename); + if (!f.exists()) { + cerr<<"ERROR: "<<filename<<" does not exist"<<endl; + return false; + } + //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+="."; + if (tokens.count()>1){ + for (int i=0;i<tokens.count()-1;i++){ + idxfile+=tokens[i]; + idxfile+="."; + } + idxfile+="idx"; } - idxfile+="idx"; - Poco::File f=Poco::File(idxfile); + else idxfile=filename+".idx"; + + f=Poco::File(idxfile); bool makeindex=true; FFMS_Index *index; if (f.exists()) { @@ -54,7 +64,7 @@ bool libav::video_decoder::open(const std::string& filename){ } } if (makeindex) { - cerr<<"FFMS2: created index "<<idxfile<<endl; + cerr<<"FFMS2: creating 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); } |
