OpenToonz - An open-source full-featured 2D animation creation software
C
fix gif reader not getting all frames (#770)
Jeremy Bullock779cdf5542c6
diff --git a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cppindex 3f35abe9b..9229cd22b 100644--- a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp+++ b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp@@ -399,6 +399,26 @@ void Ffmpeg::getFramesFromMovie(int frame) {}}+int Ffmpeg::getGifFrameCount() {+ int frame = 1;+ QString ffmpegCachePath = getFfmpegCache().getQString();+ QString tempPath = ffmpegCachePath + "//" ++ QString::fromStdString(m_path.getName()) ++ QString::fromStdString(m_path.getType());+ std::string tmpPath = tempPath.toStdString();+ QString tempName = "In%04d." + m_intermediateFormat;+ tempName = tempPath + tempName;+ QString tempStart;+ tempStart = "In0001." + m_intermediateFormat;+ tempStart = tempPath + tempStart;+ while (TSystem::doesExistFileOrLevel(TFilePath(tempStart))) {+ frame++;+ QString number = QString("%1").arg(frame, 4, 10, QChar('0'));+ tempStart = tempPath + "In" + number + "." + m_intermediateFormat;+ }+ return frame - 1;+}+void Ffmpeg::addToCleanUp(QString path) {if (TSystem::doesExistFileOrLevel(TFilePath(path))) {m_cleanUpList.push_back(path);diff --git a/toonz/sources/image/ffmpeg/tiio_ffmpeg.h b/toonz/sources/image/ffmpeg/tiio_ffmpeg.hindex 4b3fe4f1f..853110a7a 100644--- a/toonz/sources/image/ffmpeg/tiio_ffmpeg.h+++ b/toonz/sources/image/ffmpeg/tiio_ffmpeg.h@@ -41,6 +41,7 @@ public:TFilePath getFfmpegCache();ffmpegFileInfo getInfo();void disablePrecompute();+ int getGifFrameCount();private:QString m_intermediateFormat, m_ffmpegPath, m_audioPath, m_audioFormat;diff --git a/toonz/sources/image/ffmpeg/tiio_gif.cpp b/toonz/sources/image/ffmpeg/tiio_gif.cppindex 089461d8a..f410ddd86 100644--- a/toonz/sources/image/ffmpeg/tiio_gif.cpp+++ b/toonz/sources/image/ffmpeg/tiio_gif.cpp@@ -190,7 +190,7 @@ TLevelReaderGif::TLevelReaderGif(const TFilePath &path)m_ly = m_size.ly;ffmpegReader->getFramesFromMovie();-+ m_frameCount = ffmpegReader->getGifFrameCount();// set valuesm_info = new TImageInfo();m_info->m_frameRate = fps;