From 686e82ae0865bc5c6013fd5ecd5c80c7cce76f1b Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Wed, 23 Nov 2016 19:11:57 -0700 Subject: [PATCH] Fixed gif import (#924) * fixed gif import --- toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp | 42 ++++++++++------------ toonz/sources/image/ffmpeg/tiio_ffmpeg.h | 1 + 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp index fc147d92..0cd7a8c0 100644 --- a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp +++ b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp @@ -221,10 +221,8 @@ void Ffmpeg::saveSoundTrack(TSoundTrack *st) { bool Ffmpeg::checkFilesExist() { QString ffmpegCachePath = getFfmpegCache().getQString(); - QString tempPath = ffmpegCachePath + "//" + - m_path.getQString().remove(QRegExp(QString::fromUtf8( - "[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))) + - "In0001." + m_intermediateFormat; + QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols() + "In0001." + + m_intermediateFormat; if (TSystem::doesExistFileOrLevel(TFilePath(tempPath))) { return true; } else @@ -233,10 +231,7 @@ bool Ffmpeg::checkFilesExist() { ffmpegFileInfo Ffmpeg::getInfo() { QString ffmpegCachePath = getFfmpegCache().getQString(); - QString tempPath = ffmpegCachePath + "//" + - m_path.getQString().remove(QRegExp(QString::fromUtf8( - "[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))) + - ".txt"; + QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols() + ".txt"; if (QFile::exists(tempPath)) { QFile infoText(tempPath); infoText.open(QIODevice::ReadOnly); @@ -269,10 +264,8 @@ ffmpegFileInfo Ffmpeg::getInfo() { } TRasterImageP Ffmpeg::getImage(int frameIndex) { QString ffmpegCachePath = getFfmpegCache().getQString(); - QString tempPath = ffmpegCachePath + "//" + - m_path.getQString().remove(QRegExp(QString::fromUtf8( - "[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))); - std::string tmpPath = tempPath.toStdString(); + QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols(); + std::string tmpPath = tempPath.toStdString(); // QString tempPath= m_path.getQString(); QString number = QString("%1").arg(frameIndex, 4, 10, QChar('0')); QString tempName = "In" + number + ".png"; @@ -361,12 +354,10 @@ int Ffmpeg::getFrameCount() { void Ffmpeg::getFramesFromMovie(int frame) { QString ffmpegCachePath = getFfmpegCache().getQString(); - QString tempPath = ffmpegCachePath + "//" + - m_path.getQString().remove(QRegExp(QString::fromUtf8( - "[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))); - std::string tmpPath = tempPath.toStdString(); - QString tempName = "In%04d." + m_intermediateFormat; - tempName = tempPath + tempName; + QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols(); + std::string tmpPath = tempPath.toStdString(); + QString tempName = "In%04d." + m_intermediateFormat; + tempName = tempPath + tempName; QString tempStart; if (frame == -1) { tempStart = "In0001." + m_intermediateFormat; @@ -405,15 +396,18 @@ void Ffmpeg::getFramesFromMovie(int frame) { } } +QString Ffmpeg::cleanPathSymbols() { + return m_path.getQString().remove(QRegExp( + QString::fromUtf8("[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))); +} + 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 tempPath = ffmpegCachePath + "//" + cleanPathSymbols(); + std::string tmpPath = tempPath.toStdString(); + QString tempName = "In%04d." + m_intermediateFormat; + tempName = tempPath + tempName; QString tempStart; tempStart = "In0001." + m_intermediateFormat; tempStart = tempPath + tempStart; diff --git a/toonz/sources/image/ffmpeg/tiio_ffmpeg.h b/toonz/sources/image/ffmpeg/tiio_ffmpeg.h index 853110a7..1ab39868 100644 --- a/toonz/sources/image/ffmpeg/tiio_ffmpeg.h +++ b/toonz/sources/image/ffmpeg/tiio_ffmpeg.h @@ -53,6 +53,7 @@ private: QVector m_cleanUpList; QStringList m_audioArgs; TUINT32 m_sampleRate; + QString cleanPathSymbols(); }; #endif