From d8339e9782f1ebcf4ce4ea21c56cee1e523ab4e6 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Oct 06 2016 08:19:46 +0000 Subject: Fix for ffmpeg named with sequence names (#826) - Now ffmpeg types can have a name such as img.0001.gif or img_0001.mp4 with no crash. close #767 --- diff --git a/toonz/sources/common/tsystem/tfilepath.cpp b/toonz/sources/common/tsystem/tfilepath.cpp index 215a042..d16a1a3 100644 --- a/toonz/sources/common/tsystem/tfilepath.cpp +++ b/toonz/sources/common/tsystem/tfilepath.cpp @@ -480,6 +480,7 @@ bool TFilePath::isRoot() const { // ritorna ""(niente tipo, niente punto), "." (file con tipo) o ".." (file con // tipo e frame) std::string TFilePath::getDots() const { + if (isFfmpegType()) return "."; int i = getLastSlash(m_path); std::wstring str = m_path.substr(i + 1); // potrei anche avere a.b.c.d dove d e' l'estensione @@ -561,7 +562,7 @@ std::string TFilePath::getLevelName() const { std::wstring TFilePath::getLevelNameW() const { int i = getLastSlash(m_path); // cerco l'ultimo slash std::wstring str = m_path.substr(i + 1); // str e' m_path senza directory - + if (isFfmpegType()) return str; int j = str.rfind(L"."); // str[j..] = ".type" if (j == (int)std::wstring::npos) return str; // no frame; no type i = str.substr(0, j).rfind(L'.'); @@ -597,6 +598,7 @@ TFilePath TFilePath::getParentDir() const // noSlash! //----------------------------------------------------------------------------- bool TFilePath::isLevelName() const { + if (isFfmpegType()) return false; try { return getFrame() == TFrameId(TFrameId::EMPTY_FRAME); } @@ -638,6 +640,15 @@ TFrameId TFilePath::getFrame() const { //----------------------------------------------------------------------------- +bool TFilePath::isFfmpegType() const { + QString type = QString::fromStdString(getType()).toLower(); + if (type == "gif" || type == "mp4" || type == "webm") + return true; + else + return false; +} + +//----------------------------------------------------------------------------- TFilePath TFilePath::withType(const std::string &type) const { assert(type.length() < 2 || type.substr(0, 2) != ".."); int i = getLastSlash(m_path); // cerco l'ultimo slash diff --git a/toonz/sources/include/tfilepath.h b/toonz/sources/include/tfilepath.h index ee04a45..0d58b5a 100644 --- a/toonz/sources/include/tfilepath.h +++ b/toonz/sources/include/tfilepath.h @@ -177,7 +177,7 @@ If the path is ":" a slash will be added*/ TFilePath getParentDir() const; // noSlash!; TFrameId getFrame() const; - + bool isFfmpegType() const; bool isLevelName() const; //{return getFrame() == TFrameId(TFrameId::EMPTY_FRAME);}; bool isAbsolute() const;